目录
ansible user模块批量修改用户密码
更改多个用户
//修改主机,账号,密码
---
- hosts: zksit
gather_facts: false
tasks:
- name: change user passwd
user: name={{ item.name }} password={{ item.chpass | password_hash('sha512') }} update_password=always
with_items:
- { name: 'jacky', chpass: 'jacky@123' }
执行
ansible-playbook userpass.yaml
拿到多用户的账号,用for循环替换下yml模版批量执行即可
更改单个用户
---
- hosts: test
gather_facts: false
tasks:
- name: Change password
user: name={{ name1 }} password={{ chpass | password_hash('sha512') }} update_password=always
执行:
ansible-playbook userpass2.yaml -e "name1=jacky chpass=jacky@123"
标签:name,用户,jacky,ansible,user,模块,password
From: https://www.cnblogs.com/liwenchao1995/p/17195918.html