I have an ansible task which creates a new user on ubuntu 12.04;
- name: Add deployment user
action: user name=deployer password=mypassword
I know that I'm late to the party, but there is another solution that I'm using. It might be handy for distros that don't have --stdin
in passwd binary.
- hosts: localhost
become: True
tasks:
- name: Change user password
shell: "yes '{{ item.pass }}' | passwd {{ item.user }}"
loop:
- { pass: 123123, user: foo }
- { pass: asdf, user: bar }
loop_control:
label: "{{ item.user }}"
Label in loop_control
is responsible for printing only username. The whole playbook or just user variables (you can use vars_files:
) should be encrypted with ansible-vault.