# ansible-pull git failures on initial clone and when repo changes.

**URL:** <https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391>\
**Category:** Ansible Project\
**Created:** [January 31, 2016, 10:52am UTC](https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391 "2016-01-31T10:52:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matt/32/1267_2.png) [@matt](https://forum.ansible.com/u/matt)\
**Post date:** [January 31, 2016, 10:52am UTC](https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391/1 "2016-01-31T10:52:39Z")

</div>

Hi,

I’m working with ansible-pull on ansible 2.0.0.2. On initial clone I get a failure on the first run. Subsequent runs are fine until the content of the git repo changes, in which case a further error is thrown. Runs when the repo doesn’t change work ok, except for a warning about the user of sudo, which isn’t configured.

Using /etc/ansible/ansible.cfg as config file  
Starting Ansible Pull at 2016-01-31 10:34:46  
/usr/bin/ansible-pull -d /var/lib/ansible-local -U [https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) -vvvv  
EXEC: /usr/bin/ansible -i “/etc/ansible/hosts” -c local -vvvv -m git -a “name=[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) dest=/var/lib/ansible-local depth=1” “localhost,testvm2,testvm2.localdomain,127.0.0.1”  
Using /etc/ansible/ansible.cfg as config file  
Loaded callback minimal of type stdout, v2.0  
ESTABLISH LOCAL CONNECTION FOR USER: root  
127.0.0.1 EXEC ( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1454236486.6-237992076205449 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1454236486.6-237992076205449 )” )  
ESTABLISH LOCAL CONNECTION FOR USER: root  
127.0.0.1 EXEC ( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1454236486.61-229596896503320 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1454236486.61-229596896503320 )” )  
127.0.0.1 PUT /tmp/tmppqj3FG TO /root/.ansible/tmp/ansible-tmp-1454236486.6-237992076205449/git  
127.0.0.1 PUT /tmp/tmpzx6CKh TO /root/.ansible/tmp/ansible-tmp-1454236486.61-229596896503320/git  
127.0.0.1 EXEC LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1454236486.6-237992076205449/git; rm -rf “/root/.ansible/tmp/ansible-tmp-1454236486.6-237992076205449/” \> /dev/null 2\>&1  
127.0.0.1 EXEC LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1454236486.61-229596896503320/git; rm -rf “/root/.ansible/tmp/ansible-tmp-1454236486.61-229596896503320/” \> /dev/null 2\>&1  
localhost | FAILED! =\> {  
“changed”: false,  
“cmd”: “/usr/bin/git clone --origin origin --depth 1 [https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) /var/lib/ansible-local”,  
“failed”: true,  
“invocation”: {  
“module\_args”: {  
“accept\_hostkey”: false,  
“bare”: false,  
“clone”: true,  
“depth”: 1,  
“dest”: “/var/lib/ansible-local”,  
“executable”: null,  
“force”: false,  
“key\_file”: null,  
“name”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“recursive”: true,  
“reference”: null,  
“refspec”: null,  
“remote”: “origin”,  
“repo”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“ssh\_opts”: null,  
“track\_submodules”: false,  
“update”: true,  
“verify\_commit”: false,  
“version”: “HEAD”  
},  
“module\_name”: “git”  
},  
“msg”: “fatal: destination path ‘/var/lib/ansible-local’ already exists and is not an empty directory.”,  
“rc”: 128,  
“stderr”: “fatal: destination path ‘/var/lib/ansible-local’ already exists and is not an empty directory.\n”,  
“stdout”: “”,  
“stdout\_lines”:   
}  
127.0.0.1 | SUCCESS =\> {  
“after”: “557a71b6a360ec20cf27460115ff670bff070cda”,  
“before”: null,  
“changed”: true,  
“invocation”: {  
“module\_args”: {  
“accept\_hostkey”: false,  
“bare”: false,  
“clone”: true,  
“depth”: 1,  
“dest”: “/var/lib/ansible-local”,  
“executable”: null,  
“force”: false,  
“key\_file”: null,  
“name”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“recursive”: true,  
“reference”: null,  
“refspec”: null,  
“remote”: “origin”,  
“repo”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“ssh\_opts”: null,  
“track\_submodules”: false,  
“update”: true,  
“verify\_commit”: false,  
“version”: “HEAD”  
},  
“module\_name”: “git”  
}  
}

Run after update:

Using /etc/ansible/ansible.cfg as config file  
Starting Ansible Pull at 2016-01-31 10:50:15  
/usr/bin/ansible-pull -d /var/lib/ansible-local -U [https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) -vvvv  
EXEC: /usr/bin/ansible -i “/etc/ansible/hosts” -c local -vvvv -m git -a “name=[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) dest=/var/lib/ansible-local depth=1” “localhost,testvm2,testvm2.localdomain,127.0.0.1”  
Using /etc/ansible/ansible.cfg as config file  
Loaded callback minimal of type stdout, v2.0  
ESTABLISH LOCAL CONNECTION FOR USER: root  
127.0.0.1 EXEC ( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1454237415.87-253538956035650 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1454237415.87-253538956035650 )” )  
ESTABLISH LOCAL CONNECTION FOR USER: root  
127.0.0.1 EXEC ( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1454237415.87-49409327849030 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1454237415.87-49409327849030 )” )  
127.0.0.1 PUT /tmp/tmp\_KnOu9 TO /root/.ansible/tmp/ansible-tmp-1454237415.87-253538956035650/git  
127.0.0.1 EXEC LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1454237415.87-253538956035650/git; rm -rf “/root/.ansible/tmp/ansible-tmp-1454237415.87-253538956035650/” \> /dev/null 2\>&1  
127.0.0.1 PUT /tmp/tmpaPeKpU TO /root/.ansible/tmp/ansible-tmp-1454237415.87-49409327849030/git  
127.0.0.1 EXEC LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1454237415.87-49409327849030/git; rm -rf “/root/.ansible/tmp/ansible-tmp-1454237415.87-49409327849030/” \> /dev/null 2\>&1  
127.0.0.1 | FAILED! =\> {  
“changed”: false,  
“failed”: true,  
“invocation”: {  
“module\_args”: {  
“accept\_hostkey”: false,  
“bare”: false,  
“clone”: true,  
“depth”: 1,  
“dest”: “/var/lib/ansible-local”,  
“executable”: null,  
“force”: false,  
“key\_file”: null,  
“name”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“recursive”: true,  
“reference”: null,  
“refspec”: null,  
“remote”: “origin”,  
“repo”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“ssh\_opts”: null,  
“track\_submodules”: false,  
“update”: true,  
“verify\_commit”: false,  
“version”: “HEAD”  
},  
“module\_name”: “git”  
},  
“msg”: “Failed to download remote objects and refs: error: cannot lock ref ‘refs/remotes/origin/master’: ref refs/remotes/origin/master is at b0c67413e18de8daea2e613b05a2d942ef6147ee but expected 557a71b6a360ec20cf27460115ff670bff070cda\nFrom [https://github.com/mattwillsher/turbo-telegram\n](https://github.com/mattwillsher/turbo-telegram%5Cn) ! 557a71b…b0c6741 master → origin/master (unable to update local ref)\n”  
}  
localhost | SUCCESS =\> {  
“after”: “b0c67413e18de8daea2e613b05a2d942ef6147ee”,  
“before”: “557a71b6a360ec20cf27460115ff670bff070cda”,  
“changed”: true,  
“invocation”: {  
“module\_args”: {  
“accept\_hostkey”: false,  
“bare”: false,  
“clone”: true,  
“depth”: 1,  
“dest”: “/var/lib/ansible-local”,  
“executable”: null,  
“force”: false,  
“key\_file”: null,  
“name”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“recursive”: true,  
“reference”: null,  
“refspec”: null,  
“remote”: “origin”,  
“repo”: “[https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git)”,  
“ssh\_opts”: null,  
“track\_submodules”: false,  
“update”: true,  
“verify\_commit”: false,  
“version”: “HEAD”  
},  
“module\_name”: “git”  
}  
}

---

<div class="post-metadata">

**Author:** ![matt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matt/32/1267_2.png) [@matt](https://forum.ansible.com/u/matt)\
**Post date:** [January 31, 2016, 11:07am UTC](https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391/2 "2016-01-31T11:07:02Z")

</div>

Specifying -i localhost on pull solved the issue. Is appears that the default inventory contains localhost and 127.0.0.1 among others.  
The same affect is achieved by adding localhost to /etc/ansible/hosts, which also gets rid of a host warning during the ansible run.

/usr/bin/ansible-pull -d /var/lib/ansible-local -U [https://github.com/mattwillsher/turbo-telegram.git](https://github.com/mattwillsher/turbo-telegram.git) -i localhost

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 1, 2016, 3:13pm UTC](https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391/3 "2016-02-01T15:13:54Z")

</div>

This is 'fixed' in current devel, we were improperly passing this info  
to the ansible call that cloned the repo, it should only have been  
passed to the ansible-playbook task that actually used it.

---

<div class="post-metadata">

**Author:** ![Govindaraj\_Venkatesa](https://avatars.discourse-cdn.com/v4/letter/g/a698b9/32.png) [@Govindaraj\_Venkatesa](https://forum.ansible.com/u/Govindaraj_Venkatesa)\
**Post date:** [March 16, 2016, 5:16pm UTC](https://forum.ansible.com/t/ansible-pull-git-failures-on-initial-clone-and-when-repo-changes/20391/4 "2016-03-16T17:16:03Z")

</div>

Hi All,

I am facing the same issue as “no hosts matched” and the ansible-pull is taking only localhost. It is not able to see any of my hosts.

Here is how i am using the command  
ansible-pull -U [git@github.com](mailto:git@github.com):XPlat/caps-sps.git -d /home/gvenka008c/caps-sps jenkins\_mesos\_icinga.yml -i caps-sps/jenkins\_mesos/ansible/inventory

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

I am running on Cent OS

$ uname -a  
Linux jansible-cmce-01p. 3.10.0-327.10.1.el7.x86\_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86\_64 x86\_64 x86\_64 GNU/Linux

$ ansible --version  
ansible 2.0.1.0

Let me know if any details required. Thanks.
