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
posted @ 2023-03-20 15:07  LB_运维技术  阅读(23)  评论(0编辑  收藏  举报