2022-10-27 10:53:10 +00:00
|
|
|
- hosts: demo
|
|
|
|
gather_facts: no
|
|
|
|
tasks:
|
|
|
|
- name: Gather posix account
|
2022-10-28 10:28:41 +00:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: >
|
2023-02-10 06:07:20 +00:00
|
|
|
users=$(getent passwd | grep -v nologin | grep -v shutdown | awk -F":" '{ print $1 }');for i in $users;
|
2023-05-23 08:04:14 +00:00
|
|
|
do k=$(last -w -F $i -1 | head -1 | grep -v ^$ | awk '{ print $0 }')
|
2023-02-10 06:07:20 +00:00
|
|
|
if [ -n "$k" ]; then
|
|
|
|
echo $k
|
|
|
|
else
|
|
|
|
echo $i
|
|
|
|
fi;done
|
2022-10-27 10:53:10 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Define info by set_fact
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
info: "{{ result.stdout_lines }}"
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: info
|