-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworking role to simplify and bring up to current standards
- Loading branch information
Tristan Findley
committed
Oct 25, 2024
1 parent
37ccf00
commit 4934148
Showing
23 changed files
with
145 additions
and
415 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
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 |
---|---|---|
@@ -1,61 +1,73 @@ | ||
Role Name | ||
========= | ||
# Users and Groups | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
## Requirements | ||
|
||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. | ||
|
||
Role Variables | ||
-------------- | ||
## Role Variables | ||
|
||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. | ||
|
||
Dependencies | ||
------------ | ||
## Dependencies | ||
|
||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. | ||
|
||
Generate password | ||
----------------- | ||
python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())' | ||
|
||
Example Playbook | ||
---------------- | ||
## Example Playbook | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
- hosts: servers | ||
become: yes | ||
gather_facts: true | ||
roles: | ||
- role: '/home/tristan/ansible/roles_vss/users' | ||
vars: | ||
|
||
groups_present: | ||
- "ansible" | ||
|
||
groups_absent: | ||
- "group_to_delete | ||
|
||
users_present: | ||
- {username: user1, sudo: True, enabled: True, fname: User, sname: One, groups: "ansible", email: [email protected], password: EncryptedPasswordUser1, rsa: "https://github.com/user1.keys" } | ||
- {username: user2, sudo: True, enabled: True, fname: User, sname: Two, groups: "ansible", email: [email protected], password: EncryptedPasswordUser2, rsa: "ssh-rsa enteryourrpublickeystringhere [email protected]" } | ||
- {username: user3, sudo: True, enabled: False, fname: User, sname: Three, groups: "ansible", email: [email protected], password: EncryptedPasswordUser3, rsa: } | ||
- {username: user4, sudo: False, enabled: True, fname: User, sname: Four, groups: "ansible", email: [email protected], password: EncryptedPasswordUser4, rsa: "user2_id_rsa.pub"} | ||
|
||
users_absent: | ||
- "user5" | ||
- "user6" | ||
|
||
License | ||
------- | ||
```yml | ||
- hosts: servers | ||
become: yes | ||
gather_facts: true | ||
roles: | ||
- role: 'usersandgroups' | ||
vars: | ||
|
||
# Adding a user | ||
- username: "username" | ||
state: present | ||
fname: "user" | ||
sname: "name" | ||
email: [email protected] | ||
password: 'set using openssl passwd -6' | ||
sudo: true | ||
groups: | ||
- "grouphere" | ||
sshkeys: | ||
- 'copypaste ssh key' | ||
- 'or use file read' | ||
|
||
# Removing a user | ||
- username: "another.user" | ||
state: absent | ||
|
||
# Managing Groups | ||
usersandgroups_groups: | ||
- name: "dcinfra" | ||
state: present | ||
``` | ||
### Generate password | ||
Preferred method: | ||
```bash | ||
set using openssl passwd -6 | ||
``` | ||
|
||
Alternative method: | ||
```bash | ||
python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())' | ||
``` | ||
|
||
|
||
## License | ||
|
||
BSD | ||
|
||
Author Information | ||
------------------ | ||
## Author Information | ||
|
||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
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 |
---|---|---|
@@ -1,2 +1,26 @@ | ||
--- | ||
# defaults file for users | ||
# defaults file for users | ||
|
||
usersandgroups_users: | ||
# Adding a user | ||
- username: "username" | ||
state: present | ||
fname: "user" | ||
sname: "name" | ||
email: [email protected] | ||
password: 'set using openssl passwd -6' | ||
sudo: true | ||
groups: | ||
- "grouphere" | ||
sshkeys: | ||
- 'copypaste ssh key' | ||
- 'or use file read' | ||
|
||
# Removing a user | ||
- username: "another.user" | ||
state: absent | ||
|
||
# Managing Groups | ||
usersandgroups_groups: | ||
- name: "dcinfra" | ||
state: present |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
# handlers file for users | ||
# handlers file for 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.