# Double provisioning when running Ansible locally

**URL:** <https://forum.ansible.com/t/double-provisioning-when-running-ansible-locally/18107>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [April 28, 2015, 3:54pm UTC](https://forum.ansible.com/t/double-provisioning-when-running-ansible-locally/18107 "2015-04-28T15:54:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warren\_Seine](https://avatars.discourse-cdn.com/v4/letter/w/ac8455/32.png) [@Warren\_Seine](https://forum.ansible.com/u/Warren_Seine)\
**Post date:** [April 28, 2015, 3:54pm UTC](https://forum.ansible.com/t/double-provisioning-when-running-ansible-locally/18107/1 "2015-04-28T15:54:39Z")

</div>

Hi,

I’m using Ansible to deploy to a single machine. I run Ansible locally on the target machine and I’m collecting the inventory from a script that returns JSON. I run everything from Vagrant but the actual command line being run on the target machine is:

$ ansible-playbook -i provisioning/inventory provision.yml --connection=local --limit=staging

The playbook works but is run twice on the same machine: once with the hostname and once with the IP, as shown with a sample task below:

==\> staging: TASK: [front-web | start apache2 service] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
==\> staging: ok: [[staging.example.org](http://staging.example.org)]  
==\> staging: ok: [62.xx.xx.xx]

And in the end:

==\> staging: PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
==\> staging: 62.xx.xx.xx : ok=278 changed=1 unreachable=0 failed=0  
==\> staging: [staging.example.org](http://staging.example.org) : ok=278 changed=1 unreachable=0 failed=0

The issue does not happen when I run Ansible from a control machine: only “[staging.example.org](http://staging.example.org)” gets provisioned, which is the desired behavior.

Here’s a stripped JSON produced by the script.

{  
“local”: {  
“hosts”: [  
“example.local”  
],  
“vars”: {  
“hostname”: “example.local”,  
“ansible\_ssh\_host”: “192.168.42.42”  
}  
},  
“staging”: {  
“hosts”: [  
“[staging.example.org](http://staging.example.org)”  
],  
“vars”: {  
“hostname”: “[staging.example.org](http://staging.example.org)”,  
“ansible\_ssh\_host”: “62.xx.xx.xx”,  
“ansible\_ssh\_user”: “ubuntu”,  
“ansible\_ssh\_private\_key\_file”: “key/staging.example.org.pem”  
}  
}  
}

Any idea what’s causing the “double-provisioning”?

Thank you,  
Warren.

---

<div class="post-metadata">

**Author:** ![Warren\_Seine](https://avatars.discourse-cdn.com/v4/letter/w/ac8455/32.png) [@Warren\_Seine](https://forum.ansible.com/u/Warren_Seine)\
**Post date:** [May 13, 2015, 6:54pm UTC](https://forum.ansible.com/t/double-provisioning-when-running-ansible-locally/18107/2 "2015-05-13T18:54:27Z")

</div>

I found the issue.

For some reason, ansible\_ssh\_host triggers this unexpected behavior here. Using the IP addresses as host instead worked fine for me. I rewrote my script to produce the following JSON:

{  
“local”: {  
“hosts”: [  
“192.168.42.42”  
],  
“vars”: {  
“hostname”: “example.local”  
}  
},  
“staging”: {  
“hosts”: [  
“62.xx.xx.xx”  
],  
“vars”: {  
“hostname”: “[staging.example.org](http://staging.example.org/)”,  
“ansible\_ssh\_user”: “ubuntu”,  
“ansible\_ssh\_private\_key\_file”: “key/staging.example.org.pem”  
}  
}  
}
