ansible批量执行输出所有账户
[root@libin3]# cat libin.yml
- hosts: task gather_facts: no tasks: - name: fetch shell: | for i in `awk -F':' '{if( $3>=500 )print $1 }' /etc/passwd | grep -Ev 'libin1|root|libin2'`;do passwd -S $i;done | awk '{print "{{ inventory_hostname }}",$1,$2,$3,$5}' | sed -r 's/[ ]/,/g' register: serial - name: dd shell: | echo "{{serial.stdout}},{{inventory_hostname}}" >> libin.csv delegate_to: localhost

浙公网安备 33010602011771号