Skip to content

Instantly share code, notes, and snippets.

@riskiwah
Created October 5, 2022 15:41
Show Gist options
  • Save riskiwah/76e37f896b04e41153810f195292d487 to your computer and use it in GitHub Desktop.
Save riskiwah/76e37f896b04e41153810f195292d487 to your computer and use it in GitHub Desktop.
simple ansible playbook check user expired
---
- 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