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

777 views
Skip to first unread message

Matt Willsher

unread,
Jan 31, 2016, 5:52:40 AM1/31/16
to Ansible Project
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 -vvvv
EXEC: /usr/bin/ansible -i "/etc/ansible/hosts" -c local  -vvvv -m git -a "name=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 /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, 
            "recursive": true, 
            "reference": null, 
            "refspec": null, 
            "remote": "origin", 
            "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, 
            "recursive": true, 
            "reference": null, 
            "refspec": null, 
            "remote": "origin", 
            "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 -vvvv
EXEC: /usr/bin/ansible -i "/etc/ansible/hosts" -c local  -vvvv -m git -a "name=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, 
            "recursive": true, 
            "reference": null, 
            "refspec": null, 
            "remote": "origin", 
            "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 ! 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, 
            "recursive": true, 
            "reference": null, 
            "refspec": null, 
            "remote": "origin", 
            "ssh_opts": null, 
            "track_submodules": false, 
            "update": true, 
            "verify_commit": false, 
            "version": "HEAD"
        }, 
        "module_name": "git"
    }
}

Matt Willsher

unread,
Jan 31, 2016, 6:07:02 AM1/31/16
to Ansible Project


On Sunday, 31 January 2016 10:52:40 UTC, Matt Willsher wrote:
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.


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 -i localhost 

Brian Coca

unread,
Feb 1, 2016, 10:14:10 AM2/1/16
to Ansible Project
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.



--
Brian Coca

Govindaraj Venkatesan

unread,
Mar 16, 2016, 1:16:04 PM3/16/16
to Ansible Project
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 g...@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.
Reply all
Reply to author
Forward
0 new messages