On 04.04.2017 22:33, [email protected] wrote:
i am trying to get this to work, but its skipping over user creation in this current form when getent returns a null answer--- - hosts: test remote_user: ansible become: yes gather_facts: yes vars: user_name: yourusername vars_prompt: - name: "encrypted_user_password" prompt: "Enter New Password" private: yes encrypt: "md5_crypt" confirm: yes salt_size: 7 tasks: - name: Get information about the user getent: key={{user_name}} database=passwd fail_key=true - name: Create user account user: name={{ user_name }} password={{ encrypted_user_password }} state=present append=yes groups=sudo shell="/bin/bash" update_password=always when: getent_passwd[user_name] != none
Here you say run user module when getent_passwd[user_name] is not none/null, aka the user already exist.
Change it to "==" instead of "!=" and it should work. -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2ff8b433d3a2134aead9d82005c9609d%40olstad.com. For more options, visit https://groups.google.com/d/optout.
