On 30.09.2016 11:50, hzj...@foxmail.com wrote:
i tried, the playbook still creates the user if user not exists on
the remote hosts ;
You'll need to add a test to check if the user exist and use a when on
the update password task.
---
- hosts: localhost
remote_user: root
become: yes
gather_facts: yes
vars:
user_name: youruser
vars_prompt:
- name: "new_password"
prompt: "Enter New Password"
private: yes
encrypt: "md5_crypt"
confirm: yes
salt_size: 7
tasks:
- name: Change password of existing user
user: name={{user_name}} update_password=always
password={{new_password}}
tasks:
- name: Get information about the user
getent:
key={{user_name}}
database=passwd
fail_key=false
- name: Change password of existing user
user:
name={{user_name}}
update_password=always
password={{new_password}}
when: getent_passwd[user_name] != None
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/100af417a6c3674c2956c073c0a603e1%40olstad.com.
For more options, visit https://groups.google.com/d/optout.