Skip to content

Commit

Permalink
Fixed abiity to add multiple secondary groups.
Browse files Browse the repository at this point in the history
You need to pass a string of groups to add user to. If you do it via a list, each time the user group will ber over written by the next item in the list.

Signed-off-by: Sergei Filippov <[email protected]>
  • Loading branch information
sergeifilippov committed Jul 27, 2017
1 parent 38d29a0 commit f6a020d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ deployer__public_keys: []
deployer__groups_to_join:
- sudo
- ssh
- www-data

## Array of sudoer actions that can be performed by deployer
### NOTE: sudo will ignore any files with filename containging a period/dot (.) or ~
Expand Down
10 changes: 8 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
state: present
register: deployer_group_created

- name: Create secondary groups
group:
name: "{{ item }}"
state: present
with_items: "{{ deployer__groups_to_join }}"
register: deployer_secondary_groups_created

- name: Create deployment user"
when: deployer_group_created|success
user: |
Expand All @@ -22,8 +29,7 @@
when: deployer_created|success
user: >
name="{{ deployer__username }}"
groups="{{ item }}"
with_items: "{{ deployer__groups_to_join }}"
groups="{{ deployer__groups_to_join | join(',') }}"
- name: Add Deployer Authorised Key
when: deployer_created|success
Expand Down

0 comments on commit f6a020d

Please sign in to comment.