0

I am trying to execute a git clone command in my Ansible playbook. It looks like this:

- name: a play that runs entirely on the ansible host
  hosts: 127.0.0.1
  connection: local
  tasks:
  - name: check out a git repository
    git: repo={{ repo_url }} dest=/Dest/For/Cloning/ accept_hostkey=yes
    vars:
      repo_url: git@github.com:lorin/mezzanine-example.git

And, my cfg file looks like this:

[defaults]
transport = ssh

[ssh_connection]
ssh_args= -A

However, when I'm running the command: ansible-playbook -i "localhost," -c local GitClone.yaml, I get the Permission denied (publickey) error.

I want to clone a gh repo to my local[specified file path].

techraf
  • 64,883
  • 27
  • 193
  • 198
Dawny33
  • 10,543
  • 21
  • 82
  • 134

1 Answers1

1

This looks like you want to clone someone else's public repo and likely never to push back to GitHub.

You don't need to provide GitHub credentials for that, so just use the HTTPS transport:

repo_url: https://github.com/lorin/mezzanine-example.git

As a side note: when you use -c local in the ansible-playbook call you override transport settings from the ansible.cfg. Settings in your example file are ignored.

techraf
  • 64,883
  • 27
  • 193
  • 198