Difference between revisions of "Ansible User Commands"
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
home: /home/robert | home: /home/robert | ||
shell: /bin/bash | shell: /bin/bash | ||
=Add Password for User= | |||
--- | |||
- name: Add or update user password | |||
hosts: all | |||
tasks: | |||
- name: Change robert password | |||
user: | |||
name: robert | |||
update_password: always | |||
password: " {{ newpassword|password_hash('sha512') }} " | |||
'''Run Playbook''' | |||
ansible-playbook updatepassword.yml --extra-vars newpassword=outwater --private-key ~/.ssh/ansible |
Revision as of 16:04, 23 June 2022
Create a user
--- - name: Playbook for creating users hosts: all tasks: - name: create user user: name: robert home: /home/robert shell: /bin/bash
Add Password for User
---
- name: Add or update user password
hosts: all tasks: - name: Change robert password user: name: robert update_password: always password: " Template:Newpassword "
Run Playbook
ansible-playbook updatepassword.yml --extra-vars newpassword=outwater --private-key ~/.ssh/ansible