Skip to content

Commit c53ae29

Browse files
authoredJun 21, 2019
Merge pull request #59 from colinhoglund/linting
Linting to boost that content score!
2 parents ca5c1f2 + e9a1892 commit c53ae29

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed
 

‎tasks/main.yml

+40-35
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,72 @@
11
---
22
- name: Creating groups
3-
group: name="{{item.name}}" gid="{{item.gid | default(omit)}}"
4-
with_items: "{{groups_to_create}}"
5-
tags: ['users','groups','configuration']
3+
group:
4+
name: "{{ item.name }}"
5+
gid: "{{ item.gid | default(omit) }}"
6+
with_items: "{{ groups_to_create }}"
7+
tags: ["users", "groups", "configuration"]
68

79
- name: Per-user group creation
8-
group: name="{{item.username}}"
9-
gid="{{item.gid | default(item.uid) | default(omit)}}"
10-
with_items: "{{users}}"
10+
group:
11+
name: "{{ item.username }}"
12+
gid: "{{ item.gid | default(item.uid) | default(omit) }}"
13+
with_items: "{{ users }}"
1114
when: "'group' not in item and users_create_per_user_group"
12-
tags: ['users','configuration']
15+
tags: ["users", "configuration"]
1316

1417
- name: User creation
1518
user:
16-
name: "{{item.username}}"
17-
group: "{{item.group | default(item.username if users_create_per_user_group else users_group)}}"
19+
name: "{{ item.username }}"
20+
group: "{{ item.group | default(item.username if users_create_per_user_group else users_group) }}"
1821
# empty string removes user from all secondary groups
19-
groups: "{{item.groups | join(',') if 'groups' in item else ''}}"
20-
append: "{{item.append | default(omit)}}"
21-
shell: "{{item.shell if item.shell is defined else users_default_shell}}"
22-
password: "{{item.password if item.password is defined else '!'}}"
23-
comment: "{{item.name if item.name is defined else ''}}"
24-
uid: "{{item.uid | default(omit)}}"
22+
groups: "{{ item.groups | join(',') if 'groups' in item else '' }}"
23+
append: "{{ item.append | default(omit) }}"
24+
shell: "{{ item.shell if item.shell is defined else users_default_shell }}"
25+
password: "{{ item.password if item.password is defined else '!' }}"
26+
comment: "{{ item.name if item.name is defined else '' }}"
27+
uid: "{{ item.uid | default(omit) }}"
2528
home: "{{ item.home | default('/home/' + item.username) }}"
26-
createhome: "{{'yes' if users_create_homedirs else 'no'}}"
29+
createhome: "{{ 'yes' if users_create_homedirs else 'no' }}"
2730
generate_ssh_key: "{{ item.generate_ssh_key | default(omit) }}"
28-
update_password: "{{item.update_password | default(omit)}}"
29-
with_items: "{{users}}"
30-
tags: ['users','configuration']
31+
update_password: "{{ item.update_password | default(omit) }}"
32+
with_items: "{{ users }}"
33+
tags: ["users", "configuration"]
3134

3235
- name: SSH keys
3336
authorized_key:
34-
user: "{{item.0.username}}"
35-
key: "{{item.1}}"
37+
user: "{{ item.0.username }}"
38+
key: "{{ item.1 }}"
3639
path: "{{ item.0.home | default('/home/' + item.0.username) }}/{{ authorized_keys_file }}"
3740
with_subelements:
38-
- "{{users}}"
41+
- "{{ users }}"
3942
- ssh_key
4043
- skip_missing: yes
41-
tags: ['users','configuration']
44+
tags: ["users", "configuration"]
4245

4346
- name: Setup user profiles
4447
blockinfile:
45-
block: "{{item.profile}}"
48+
block: "{{ item.profile }}"
4649
dest: "{{ item.home | default('/home/' + item.username) }}/.profile"
47-
owner: "{{item.username}}"
48-
group: "{{item.group | default(item.username if users_create_per_user_group else users_group)}}"
50+
owner: "{{ item.username }}"
51+
group: "{{ item.group | default(item.username if users_create_per_user_group else users_group) }}"
4952
mode: 0644
5053
create: true
5154
when: users_create_homedirs and item.profile is defined
52-
with_items: "{{users}}"
55+
with_items: "{{ users }}"
5356

5457
- name: Deleted user removal
5558
user:
56-
name: "{{item.username}}"
59+
name: "{{ item.username }}"
5760
state: absent
58-
remove: "{{item.remove | default(omit)}}"
59-
force: "{{item.force | default(omit)}}"
60-
with_items: "{{users_deleted}}"
61-
tags: ['users','configuration']
61+
remove: "{{ item.remove | default(omit) }}"
62+
force: "{{ item.force | default(omit) }}"
63+
with_items: "{{ users_deleted }}"
64+
tags: ["users", "configuration"]
6265

6366
- name: Deleted per-user group removal
64-
group: name="{{item.username}}" state=absent
65-
with_items: "{{users_deleted}}"
67+
group:
68+
name: "{{ item.username }}"
69+
state: absent
70+
with_items: "{{ users_deleted }}"
6671
when: users_create_per_user_group
67-
tags: ['users','configuration']
72+
tags: ["users", "configuration"]

‎tests/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
- hosts: localhost
43
remote_user: root
54
vars:

0 commit comments

Comments
 (0)
Please sign in to comment.