0

Hi I have enterprise git server where I created a private test-repo and added a ssh-key on the deploy ssh key form. I defined a git role in my common roles which is having below yml definition.

---

- name: github enterprise private key
  copy: >
    src=id_rsa_ghe
    dest=/etc/id_rsa_ghe
    owner=root
    group=root
    mode=0600

- name: clone test-repo project
  git:
    repo: git@git.example-private.com:code/test-repo.git
    dest: /etc/test-repo
    accept_hostkey: true
    key_file: /etc/id_rsa_ghe

in roles/common/git I defined files folder where I put my private key for git clone however I am still getting error as below

fatal: [localhost]: FAILED! => {"changed": false, "cmd": ["/usr/bin/git", "fetch", "--tags", "origin"], "failed": true, "msg": "Failed to download remote objects and refs: ERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n"}

Below are my system details. And I am running this playbook locally on one of my server.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty

$ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

Below is the actual error which I get repository not found.

Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/source_control/git.py <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507" && echo ansible-tmp-1487398723.48-100968102221507="echo ~/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507" ) && sleep 0' <127.0.0.1> PUT /tmp/tmp2Bijvu TO /home/ubuntu/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507/git.py <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507/ /home/ubuntu/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507/git.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507/git.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1487398723.48-100968102221507/"

/dev/null 2>&1 && sleep 0' fatal: [localhost]: FAILED! => { "changed": false, "cmd": [ "/usr/bin/git", "fetch", "--tags", "origin" ], "failed": true, "invocation": { "module_args": { "accept_hostkey": true, "bare": false, "clone": true, "depth": null, "dest": "/etc/dotfiles", "executable": null, "force": false, "key_file": "/etc/id_rsa_ghe", "recursive": true, "reference": null, "refspec": null, "remote": "origin", "repo": "git@git.example-private.com:code/test-repo.git", "ssh_opts": null, "track_submodules": false, "umask": null, "update": true, "verify_commit": false, "version": "HEAD" }, "module_name": "git" }, "msg": "Failed to download remote objects and refs: ERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n" }

  • The error message is pretty clear, but you provide no information related to it. Can you clone the repository using git? How do you do it? – techraf Feb 18 '17 at 1:50
  • run your playbook with -vvv – Jacob Evans Feb 18 '17 at 4:42
0

Looks like your clone test-repo project task has an syntax error and that is why Ansible can't find the repository. Replace the : with / for the repo parameter like this:

- name: clone test-repo project
  git:
    repo: git@git.example-private.com/code/test-repo.git
    dest: /etc/test-repo
    accept_hostkey: true
    key_file: /etc/id_rsa_ghe

You would use : to define a non standard port.

  • Error is still there only difference is now it says fatal: 'git@git.example-private.com/code/test-repo.git' does not appear to be a git repository – Shailesh Sutar Feb 18 '17 at 10:28
  • First guess: remove the .git. Can you checkout the repo on cmd with: git clone git@git.example-private.com/code/test-repo.git? Otherwise read git-scm.com/book/en/v2/… – Henrik Pingel Feb 18 '17 at 10:36

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .