-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add role for htpasswd-from-dict (#398)
- Loading branch information
1 parent
f903178
commit be59970
Showing
6 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
htpasswd-from-dict | ||
================== | ||
|
||
Create a htpasswd file based on a dictionary list | ||
|
||
Requirements | ||
------------ | ||
|
||
This module will require passlib to be installed | ||
|
||
Role Variables | ||
-------------- | ||
|
||
| Name | Description | Default | Required | | ||
| ---- | ----------- | ------- | -------- | | ||
| htpasswd_output_path | Where to write the htpasswd file | /tmp/htpasswd | no | | ||
| htpasswd_users | List of usernames & passwords| [] | no | | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role | ||
``` | ||
--- | ||
- hosts: localhost | ||
roles: | ||
- identity-management/htpasswd-from-dict | ||
vars: | ||
htpasswd_output_path: /var/www/htpasswd | ||
htpasswd_users: | ||
- username: user1 | ||
password: password1 | ||
- username: user2 | ||
password: password2 | ||
``` | ||
|
||
License | ||
------- | ||
|
||
Apache License 2.0 | ||
|
||
Author Information | ||
------------------ | ||
|
||
Red Hat Community of Practice & staff of the Red Hat Open Innovation Labs. |
9 changes: 9 additions & 0 deletions
9
roles/identity-management/htpasswd-from-dict/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
htpasswd_output_path: /tmp/htpasswd | ||
htpasswd_users: [] | ||
|
||
# htpasswd_users: | ||
# - username: user1 | ||
# password: password1 | ||
# - username: user2 | ||
# password: password2 |
17 changes: 17 additions & 0 deletions
17
roles/identity-management/htpasswd-from-dict/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: Ensure {{ htpasswd_output_path | dirname }} exist | ||
file: | ||
path: "{{ htpasswd_output_path | dirname }}" | ||
state: directory | ||
|
||
- name: Delete old htpasswd file (if it exist) | ||
file: | ||
path: "{{ htpasswd_output_path }}" | ||
state: absent | ||
|
||
- name: Create htpasswd file | ||
htpasswd: | ||
path: "{{ htpasswd_output_path }}" | ||
name: "{{ item.username }}" | ||
password: "{{ item.password }}" | ||
loop: "{{ htpasswd_users }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../roles |
12 changes: 12 additions & 0 deletions
12
roles/identity-management/htpasswd-from-dict/tests/test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: localhost | ||
remote_user: root | ||
roles: | ||
- identity-management/htpasswd-from-dict | ||
vars: | ||
htpasswd_users: | ||
- username: user1 | ||
password: password1 | ||
- username: user2 | ||
password: password2 | ||
htpasswd_output_path: /tmp/ansible-test/htpasswd |