Skip to content

Commit d31bbfc

Browse files
author
Conor Schaefer
committed
Supports --check mode
By setting always_run=true on a few read-only tasks that are used to register variables, we add support for dry runs of the role via the --check flag to ansible-playbook. The role now completes without error in dry-run mode, which is very useful when onboarding new hosts to the role.
1 parent 371ed47 commit d31bbfc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

tasks/rhosts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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
56
register: users
67

78
- name: delete rhosts-files from system | DTAG SEC Req 3.21-4

tasks/user_accounts.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +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
67
changed_when: False
78

89
- name: calculate UID_MAX from UID_MIN by substracting 1
@@ -20,6 +21,7 @@
2021
- name: get all system accounts
2122
command: awk -F'':'' '{ if ( $3 <= {{uid_max|quote}} ) print $1}' /etc/passwd removes=/etc/passwd
2223
changed_when: False
24+
always_run: True
2325
register: sys_accs
2426

2527
- name: remove always ignored system accounts from list

0 commit comments

Comments
 (0)