ansible-playbook 批量修改密码

创建playbook脚本

vim change_passwd.yml

---
- hosts: a                     备注:ip组  配置在hosts文件中
  sudo: yes 
  remote_user: root            备注:远程的用户
  gather_facts: false
  tasks:
  - name: change user passwd
    user: name={{ item.user }} password={{ item.password | password_hash('sha512') }}  update_password=always
    with_items:
          - { user: 'version', password: '******' }     备注:修改远程服务器所有的用户和所修改成的密码******
          - { user: 'root', password: '******' }        备注:多个用户继续加

执行命令:ansible-playbook change_passwd.ym