0%

Update User Password with Ansible from Command Line

command

1
2
3
$ ansible -i hostfile all -m user \
-a "name=admin update_password=always password={{ newpassword|password_hash('sha512') }}" \
-b --extra-vars "newpassword=12345678"

reference

playbook

或許用 playbook 比較好.

1
2
3
4
5
6
7
8
9
---
- hosts: all
become: yes
tasks:
- name: Change user password
user:
name: admin
update_password: always
password: "{{ newpassword|password_hash('sha512') }}"