Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omit empty variables #106

Merged
merged 1 commit into from
Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tasks/rhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
- name: Get user accounts | DTAG SEC Req 3.21-4
command: "awk -F: '{print $1}' /etc/passwd"
changed_when: False
always_run: True
check_mode: no
register: users

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

- name: delete hosts.equiv from system | DTAG SEC Req 3.21-4
file: dest='/etc/hosts.equiv' state=absent
13 changes: 7 additions & 6 deletions tasks/user_accounts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: get UID_MIN from login.defs
shell: awk '/^\s*UID_MIN\s*([0-9]*).*?$/ {print $2}' /etc/login.defs removes=/etc/login.defs
register: uid_min
always_run: True
check_mode: no
changed_when: False

- name: calculate UID_MAX from UID_MIN by substracting 1
Expand All @@ -19,16 +19,17 @@
when: not uid_min

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

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

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