Example 2: Update passwords in a variable

Update passwords of users at host test_01. Use the same playbook and variables as in Example 1. Update the variable lp_users with the new passwords stored in the attribute userpass

 shell> cat host_vars/test_01/lp-users.yml
 lp_users:
   - {name: user1, shell: /bin/sh, userpass: user1_password}
   - {name: user2, shell: /bin/bash, userpass: user2_password}

Update the passwords

shell> ansible-playbook lp.yml -t lp_passwords -e lp_passwordstore_overwrite=True
...
TASK [vbotka.linux_postinstall : users: Manage user accounts] **********
changed: [test_01] => (item=user1)
changed: [test_01] => (item=user2)

The command is idempotent

shell> ansible-playbook lp.yml -t lp_passwords -e lp_passwordstore_overwrite=True
...

PLAY RECAP *************************************************************
test_01: ok=18 changed=0 unreachable=0 failed=0 skipped=20 rescued=0 ...

Show the passwords stored in passwordstore at the controller

shell> pass test_01
test_01
├── user1
└── user2

shell> pass test_01/user1
user1_password
lookup_pass: First generated by ansible on 01/07/2020 16:59:00

shell> pass test_01/user2
user2_password
lookup_pass: First generated by ansible on 01/07/2020 16:59:00

See the passwordstore log at the controller git log and test the new passwords at test_01.