Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pjan committed Sep 9, 2014
1 parent 5ed218c commit 87c31d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ Ansible role which manages the groups and user accounts.
```yaml
genericusers_groups:
- name: "dbadmins"
gid: 5000
system: no
- name: "mailadmins"
gid: 6000
system: no

genericusers_groups_removed:
- name: "defunctadmins"
Expand All @@ -23,12 +27,12 @@ genericusers_users:
ssh_keys:
- "ssh-dss ......."
- "ssh-dss ......."
append: "no" # (optional) If yes, will only add groups, not set them to just the list in groups.
pass: "$6$...." # (Optional) Set the user's password to this crypted value.
comment: "foo acc" # (Optional)
shell: "/bin/bash" # (Optional) Set the user's shell.
home: "/home/baz" # (Optional) Set the user's home directory.
system: no # (Optional) Make the user a system account or not.
append: "no" # If yes, will only add groups, not set them to just the list in groups.
pass: "$6$...." # Set the user's password to this crypted value.
comment: "foo acc" #
shell: "/bin/bash" # Set the user's shell.
home: "/home/baz" # Set the user's home directory.
system: no # Make the user a system account or not.
- name: "bar"
groups: ["admin", "staff", "dev"]
ssh_keys: []
Expand Down
18 changes: 9 additions & 9 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# file: generic-users/tasks/main.yml

- name: generic-users | Make sure all groups are present
group: name={{item.name}}{% if item.system is defined %} {{item.system}}{% endif %}{% if item.gid is defined %} gid={{item.gid}}{% endif %} state=present
with_items: genericusers_groups
group: name="{{item.name}}"{% if item.system is defined %} system="{{item.system}}"{% endif %}{% if item.gid is defined %} gid="{{item.gid}}"{% endif %} state=present
with_items: "{{ genericusers_groups }}"

- name: generic-users | Make sure all removed groups are not present
group: name={{item.name}} state=absent
with_items: genericusers_groups_removed
group: name="{{item.name}}" state=absent
with_items: "{{ genericusers_groups_removed }}"

- name: generic-users | Make sure the users are present
user: name={{item.name}} groups={{",".join(item.groups)}}{% if item.append is defined %} append={{item.append}}{% endif %}{% if item.pass is defined %} password={{item.pass}}{% endif %}{% if item.comment is defined %} comment='{{item.comment}}'{% endif %}{% if item.shell is defined %} shell={{item.shell}}{% endif %}{% if item.uid is defined %} uid={{item.uid}}{% endif %}{% if item.home is defined %} home={{item.home}}{% endif %}{% if item.system is defined %} system={{item.system}}{% endif %} state=present
with_items: genericusers_users
user: name="{{item.name}}" groups="{{','.join(item.groups)}}"{% if item.append is defined %} append="{{item.append}}"{% endif %}{% if item.pass is defined %} password="{{item.pass}}"{% endif %}{% if item.comment is defined %} comment='"{{item.comment}}"'{% endif %}{% if item.shell is defined %} shell="{{item.shell}}"{% endif %}{% if item.uid is defined %} uid="{{item.uid}}"{% endif %}{% if item.home is defined %} home="{{item.home}}"{% endif %}{% if item.system is defined %} system="{{item.system}}"{% endif %} state=present
with_items: "{{ genericusers_users }}"

- name: generic-users | Make sure all removed groups are not present
user: name={{item.name}} state=absent remove=yes
with_items: genericusers_users_removed
user: name="{{item.name}}" state=absent remove=yes
with_items: "{{ genericusers_users_removed }}"

- name: generic-users | Install the ssh keys for the users
authorized_key: "user={{item.0.name}} key='{{item.1}}'"
authorized_key: "user='{{item.0.name}}' key='{{item.1}}'"
with_subelements:
- genericusers_users
- ssh_keys

0 comments on commit 87c31d6

Please sign in to comment.