Difference between revisions of "Ansible User Commands"

From rbachwiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:


=Add Password for User=
=Add Password for User=
 
<pre>
  ---
  ---
  - name: Add or update user password
  - name: Add or update user password
Line 23: Line 23:
       update_password: always
       update_password: always
       password: " {{ newpassword|password_hash('sha512') }} "
       password: " {{ newpassword|password_hash('sha512') }} "
</pre>
'''Run Playbook, the "newpassword is a variable which is used on the command to hold the password'''
ansible-playbook updatepassword.yml --extra-vars newpassword=outwater --private-key ~/.ssh/ansible




'''Run Playbook'''
=[[Ansible| Ansible Menu]]=
ansible-playbook updatepassword.yml --extra-vars newpassword=outwater --private-key ~/.ssh/ansible
[[Category:Ansible]]

Latest revision as of 14:44, 24 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: " {{ newpassword|password_hash('sha512') }} "

Run Playbook, the "newpassword is a variable which is used on the command to hold the password

ansible-playbook updatepassword.yml --extra-vars newpassword=outwater --private-key ~/.ssh/ansible


Ansible Menu