使用play-book实现对主机批量修改密码。
1.在主控服务器上安装ansibleyum -y install ansible
2.编写yml文件vim /etc/ansible/conf/play.yml
---
- hosts: test
gather_facts: false
tasks:
- name: change user passwd
user: name={{ item.name }} password={{ item.chpass | password_hash('sha512') }} update_password=always
with_items:
- { name: 'root',chpass: '希望修改的新密码字符串' }
3.运行play.yml文件
ansible-playbook /etc/ansible/conf/play.yml
转载于:https://blog.51cto.com/13528748/2397642