從網上找到批量修改Linux服務器root密碼的playbook。
使用方法:
1、輸入要修改的inventory組
2、按需要,在playbook中輸入要修改的IP、新密碼,如下:
- hosts: production remote_user: root tasks: - name: change password for root shell: echo '{{ item.password }}' |passwd --stdin root when: ansible_eth0.ipv4.address == '{{ item.ip }}' with_items: - { ip: "ip1", password: 'password1' } - { ip: "ip2", password: 'password2' } - { ip: "ip3", password: 'password3' }
3、執行playbook
ansible-playbook change_passwd.yml
轉自
http://www.iyunv.com/thread-330182-1-1.html