Hi,
I am using ansible-playbook at a script and passing password to t. Below is how i used it:
run.sh
#!/bin/bash
…
/bin/expect <<- DONE
spawn ansible-playbook -i $1 $2 -u $Username -k --become-user root --become-method sudo --become
expect "SSH password: "
send “$Password\r”
expect eof
DONE
$ bash run.sh test.txt test/playbook.yml
cat cyberark.txt
[all]
FOO01
FOO02
FOO03
FOO04
FOO05
bash run.sh foo.txt test/playbook.yml
spawn ansible-playbook -i test.txt foo/playbook.yml -u testuser -k --become-user root --become-method sudo --become
SSH password:
PLAY [Swap operations] *********************************************************
TASK [setup] *******************************************************************
ok: [FOO01]
TASK [swap_ops : swapoff] ******************************************************
changed: [FOO01]
TASK [swap_ops : swapon] *******************************************************
changed: [FOO01]
PLAY [Swap operations] *********************************************************
TASK [setup] *******************************************************************
ok: [FOO02]
TASK [swap_ops : swapoff] ******************************************************
changed: [FOO02]
TASK [swap_ops : swapon] *******************************************************
changed: [FOO02]
PLAY [Swap operations] *********************************************************
TASK [setup] *******************************************************************
ok: [FOO03]
TASK [swap_ops : swapoff] ******************************************************
Any idea why the playbook is ended at the 3rd one? when i use a inventory with two hosts, everything is fine. When the number of hosts in inventory increases, ansible is ending at some hosts.
It may be because of spawn usage. Any solution will be appreciated.