Created
October 5, 2022 15:41
-
-
Save riskiwah/76e37f896b04e41153810f195292d487 to your computer and use it in GitHub Desktop.
simple ansible playbook check user expired
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: ansible user expired test | |
hosts: localhost | |
connection: local | |
become: yes | |
gather_facts: no | |
tasks: | |
- name: check user expire | |
shell: | | |
for user in $(cat /etc/passwd | cut -d: -f1) | |
do echo $user | |
chage -l $user | grep "Password expires" | |
done | paste -d "" - - | sed 's/Password expires//g' | grep -v "never" | |
changed_when: False | |
check_mode: False | |
register: echoing | |
- debug: | |
msg: "{{ echoing.stdout | replace('\t', '') | trim }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment