--- - hosts: all gather_facts: no vars_prompt: - name: _user_name prompt: "Give username here" private: no - name: _user_pass prompt: "Give user password here" private: yes encrypt: "sha512_crypt" confirm: yes salt_size: 8 tasks: - name: Check if {{ _user_name }} exists. shell: egrep "^{{ _user_name }}:" /etc/passwd || echo "user_not_exists" register: user_exists changed_when: false - debug: msg: User does not exists ! when: user_exists.stdout == 'user_not_exists' - name: Update User Password user: name: "{{ _user_name }}" update_password: always password: "{{ _user_pass }}" when: user_exists.stdout != 'user_not_exists'