My playbook: 

---
- name: Playbook to create users
  hosts: all
  become: true

  vars_files:
      - /home/devops/become_pass.yml
      - /home/devops/user_secret.yml
  vars:
     - ansible_become_password: "{{ become_pass }}"

  tasks:

     - name: User creation is in progress
       user:
          name: test321
          comment: "Test user"
          password: "{{ user_secret | password_hash('sha512', 
'mysecretsalt') }}"
          state: present

     - name: Trying remote connectivity with newly created user
       become: false
       remote_user: test
       vars:
          ansible_ssh_pass: "{{ user_secret }}"

       command:
          cmd: id
       register: x
       no_log: true

     - name: Connectivity result
       debug:
          msg: "User created successfully and remote connectivity with 
password was successful"
       when: x.rc==0
...

Here I am using vault to pass become password and password to be set for 
user..

User creation is successful and its picking up password from my encrypted 
variable..
I have tested connectivity for this user with password.. its successful..

But, I am not able to achieve same from playbook.
I guess - ansible_ssh_pass: "{{ user_secret }}" one is causing issue..
how I can ask playbook to pickup ssh password for user from encrypted 
variable?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6ec421c4-2e6c-43bb-a86e-66b81ed388ffn%40googlegroups.com.

Reply via email to