diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index 62073494ad1d4365e2efe1f5053747396ca5ef13..025152d234b3e05b510c4eb72cdd7112b4ea8b16 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -5,23 +5,23 @@ --- # file: cleanup.yml -- name: "Grab the user list" +- name: Grab the user list shell: cat /etc/passwd register: passwd -- name: "Unlock legitimate user accounts" +- name: Unlock legitimate user accounts command: usermod --unlock {{item.split(':').0}} when: item.split(':').0 in users and item.split(':').2|int > 499 with_items: '{{ passwd.stdout_lines }}' -- name: "Lock deprecated user accounts" +- name: Lock deprecated user accounts command: usermod --lock {{item.split(':').0}} when: item.split(':').0 not in users and item.split(':').2|int > 499 with_items: '{{ passwd.stdout_lines }}' -- name: "Disable ssh keys for deprecated user accounts" +- name: Disable ssh keys for deprecated user accounts command: rm {{item.split(':').5}}/.ssh/authorized_keys when: item.split(':').0 not in users and item.split(':').2|int > 499 diff --git a/tasks/main.yml b/tasks/main.yml index be1bff738fd58188b120d160a66a7031ebc1cfde..f615a5e9b7f67f227a3e55f9e6ff1bc3b58e51f8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,7 +5,7 @@ --- # file: main.yml -- name: "Check requirements: is the user hash defined" +- name: Check requirements: is the user hash defined local_action: shell echo "There are no users defined" when: not users changed_when: false