Skip to content

Commit 7fdd7b4

Browse files
authored
Merge pull request #106 from dev-sec/skip_fail
omit empty variables
2 parents 7f1415f + 0ab4db4 commit 7fdd7b4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tasks/rhosts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
- name: Get user accounts | DTAG SEC Req 3.21-4
33
command: "awk -F: '{print $1}' /etc/passwd"
44
changed_when: False
5-
always_run: True
5+
check_mode: no
66
register: users
77

88
- name: delete rhosts-files from system | DTAG SEC Req 3.21-4
99
file: dest='~{{ item }}/.rhosts' state=absent
10-
with_items: '{{ users.stdout_lines }}'
10+
with_items: '{{ users.stdout_lines | default(omit) }}'
1111

1212
- name: delete hosts.equiv from system | DTAG SEC Req 3.21-4
1313
file: dest='/etc/hosts.equiv' state=absent

tasks/user_accounts.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: get UID_MIN from login.defs
44
shell: awk '/^\s*UID_MIN\s*([0-9]*).*?$/ {print $2}' /etc/login.defs removes=/etc/login.defs
55
register: uid_min
6-
always_run: True
6+
check_mode: no
77
changed_when: False
88

99
- name: calculate UID_MAX from UID_MIN by substracting 1
@@ -19,16 +19,17 @@
1919
when: not uid_min
2020

2121
- name: get all system accounts
22-
command: awk -F'':'' '{ if ( $3 <= {{uid_max|quote}} ) print $1}' /etc/passwd removes=/etc/passwd
22+
command: awk -F'':'' '{ if ( $3 <= {{uid_max|quote}} ) print $1}' /etc/passwd removes=/etc/passwd
2323
changed_when: False
24-
always_run: True
24+
check_mode: no
2525
register: sys_accs
2626

27-
- name: remove always ignored system accounts from list
27+
- name: remove always ignored system accounts from list
2828
set_fact:
2929
sys_accs_cond: '{{sys_accs.stdout_lines | difference(os_always_ignore_users) }}'
30+
check_mode: no
3031

3132
- name: change system accounts not on the user provided ignore-list
32-
user: name='{{ item }}' shell='{{os_nologin_shell_path}}' password='*'
33+
user: name='{{item}}' shell='{{os_nologin_shell_path}}' password='*'
3334
with_items:
34-
- '{{sys_accs_cond | difference(os_ignore_users) }}'
35+
- '{{sys_accs_cond | default(omit) | difference(os_ignore_users) }}'

0 commit comments

Comments
 (0)