# Ansible seems to cache the target hosts

**URL:** <https://forum.ansible.com/t/ansible-seems-to-cache-the-target-hosts/21115>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [April 9, 2016, 5:00pm UTC](https://forum.ansible.com/t/ansible-seems-to-cache-the-target-hosts/21115 "2016-04-09T17:00:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Nanotkar](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Ashish\_Nanotkar](https://forum.ansible.com/u/Ashish_Nanotkar)\
**Post date:** [April 9, 2016, 5:00pm UTC](https://forum.ansible.com/t/ansible-seems-to-cache-the-target-hosts/21115/1 "2016-04-09T17:00:36Z")

</div>

When executed ansible playbook it does not have any effect on the hosts mentioned.

I investigated with -vvv and found that it connects to another ec2 instance than intended.

I the example below, I created a file “/home/ubuntu/hello” intentionally on wrong ec2 instance and it proved me right.

Expected: error on TASK [command] but it succeeds.

Following is the output.

I want to connect to **10.224.149.135** also mentioned in “hosts:” in the playbook but it always connects to **10.224.149.183**

Any help would be greatly appreciated. I tried my best over last couple of days but nothing seems to work. Thanks in advance.

---- output ----

ansible-playbook -i ec2.py -u ubuntu setup\_elastalert.yml -vvv

Using /etc/ansible/ansible.cfg as config file

2 plays in setup\_elastalert.yml

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

**\<10.224.149.183\>** ESTABLISH SSH CONNECTION FOR USER: ubuntu

\<10.224.149.183\> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.224.149.183 ‘/bin/sh -c ‘"’"’( umask 22 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1460220809.57-210960874166618`” && echo “`echo $HOME/.ansible/tmp/ansible-tmp-1460220809.57-210960874166618`” )‘"’"‘’

\<10.224.149.183\> PUT /tmp/tmpmwvkVs TO /home/ubuntu/.ansible/tmp/ansible-tmp-1460220809.57-210960874166618/setup

\<10.224.149.183\> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r ‘[10.224.149.183]’

\<10.224.149.183\> ESTABLISH SSH CONNECTION FOR USER: ubuntu

\<10.224.149.183\> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.224.149.183 ‘/bin/sh -c ‘"’“‘LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1460220809.57-210960874166618/setup; rm -rf “/home/ubuntu/.ansible/tmp/ansible-tmp-1460220809.57-210960874166618/” \> /dev/null 2\>&1’”’"‘’

**ok: [10.224.149.135]**

TASK [command] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

**task path: /home/ashish/gapi-ansible/setup\_elastalert.yml:4**

\<10.224.149.183\> ESTABLISH SSH CONNECTION FOR USER: ubuntu

\<10.224.149.183\> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.224.149.183 ‘/bin/sh -c ‘"’"’( umask 22 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1460220811.97-107910480855735`” && echo “`echo $HOME/.ansible/tmp/ansible-tmp-1460220811.97-107910480855735`” )‘"’"‘’

\<10.224.149.183\> PUT /tmp/tmpKDUOeZ TO /home/ubuntu/.ansible/tmp/ansible-tmp-1460220811.97-107910480855735/command

\<10.224.149.183\> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r ‘[10.224.149.183]’

\<10.224.149.183\> ESTABLISH SSH CONNECTION FOR USER: ubuntu

\<10.224.149.183\> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ashish/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.224.149.183 ‘/bin/sh -c ‘"’“‘LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1460220811.97-107910480855735/command; rm -rf “/home/ubuntu/.ansible/tmp/ansible-tmp-1460220811.97-107910480855735/” \> /dev/null 2\>&1’”’"‘’

changed: [10.224.149.135] =\> {“changed”: true, “cmd”: [“cat”, “/home/ubuntu/world”], “delta”: “0:00:00.001523”, “end”: “2016-04-09 16:53:33.677920”, “invocation”: {“module\_args”: {“\_raw\_params”: “cat /home/ubuntu/world”, “\_uses\_shell”: false, “chdir”: null, “creates”: null, “executable”: null, “removes”: null, “warn”: true}, “module\_name”: “command”}, “rc”: 0, “start”: “2016-04-09 16:53:33.676397”, “stderr”: “”, “stdout”: “Hello”, “stdout\_lines”: [“Hello”], “warnings”: }

---- end of excerpt. Bailed out ^C ----
