3

I have a small and simple playbook to make a directory on two other servers which I have saved in a inventory file and passing the name 'dev-edge'.

When I try and run this, I get a:

a2s3421.fake.cor.com : ok=0    changed=0    unreachable=1    failed=0
a1s3433.fake.cor.com : ok=0    changed=0    unreachable=1    failed=0

I can 'ssh niall@g4t7459.houston.hpecorp.net' so the servers can be reached from the ansible server.

I think this is because I am not passing my password, I have tried to use 'become_pass: XXXXX' but still doesn't work.

Can someone tell me how to add/request a password in a playbook? Or is there another reason why I would be getting a unreachable error when running the playbook??

Thanks for the help Frostie.

'Playbook'


- hosts: dev-edge
  remote_user: "{{ user }}"

  tasks:

    - name: create directories
      become: yes
      become_user: niall
      command: mkdir /opt/apps/niall_test
Frostie_the_snowman
  • 629
  • 3
  • 9
  • 17

4 Answers4

7

I solved this by passing the following when running the playbook
--extra-vars='ansible_become_pass= XXXXXXX

Frostie_the_snowman
  • 629
  • 3
  • 9
  • 17
3

To avoid specifying the password on the command line, one shall use --ask-become-pass, as told in this answer about become on sudo.

liberforce
  • 11,189
  • 37
  • 48
0

You need to run the playbook with --ask-pass option. Please refer ansible-playbook --help for more details.

Excerpt from the help:

    -k, --ask-pass      ask for connection password
Amit
  • 1,006
  • 1
  • 7
  • 13
0

You can either run with --ask-pass or use password-less ssh.

Mohan Kumar P
  • 3,122
  • 1
  • 14
  • 17