diff --git a/README.md b/README.md index 044b8a2..937fce1 100644 --- a/README.md +++ b/README.md @@ -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" @@ -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: [] diff --git a/tasks/main.yml b/tasks/main.yml index 15aabd3..8455fb8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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