Advanced Control over Role Requirements Files (git clone ssh)

1,223 views
Skip to first unread message

Patrick Schirch

unread,
Sep 4, 2014, 3:45:53 PM9/4/14
to ansible...@googlegroups.com
Hi,

i want to share internal organization ansible roles from our gitlab instance with my colleagues.
  1. I installed Ansible 1.8 dev from source.
  2. Created a requirements.yml.
  3. Added a repo from the gitlab instance (src: git+https://ourgitlabhost/example-group/example-role.git)
  4. Executing ansible-galaxy install -r requirements.yml

It only uses https (with git config http.sslVerify false ) to clone the repo sucessfully.

What is the right syntax to use SSH for cloning?

Michael DeHaan

unread,
Sep 4, 2014, 9:33:52 PM9/4/14
to ansible...@googlegroups.com
Let me make sure I understand the question ...

Are you asking what to put in the requirements.yml file so that it can download the above github role?




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/99ba978d-3723-46c0-a24e-db02f2d54155%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Patrick Schirch

unread,
Sep 5, 2014, 1:32:35 AM9/5/14
to ansible...@googlegroups.com
Right, I want to know how I can use SSH for cloning.

 - src: git@ourgitlabhost:example-group/example-role.git

doesn't work.

Michael DeHaan

unread,
Sep 5, 2014, 3:05:39 PM9/5/14
to ansible...@googlegroups.com
When you say doesn't work, please let us know what doesn't work means.

ssh://username:password@host/path.git

Needs to know it's SSH, basically






Patrick Schirch

unread,
Sep 7, 2014, 1:27:40 PM9/7/14
to ansible...@googlegroups.com
ssh://git@ourgitlabhost:example-group/example-role.git

ansible-galaxy install -r requirements.yml
- downloading role from ssh://git@ourgitlabhost:example-group/example-role.git
- error: failed to download the file.
- example-role was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.

Michael DeHaan

unread,
Sep 7, 2014, 1:37:14 PM9/7/14
to ansible...@googlegroups.com
IIRC, an issue with role dependencies and the ansible-galaxy CLI has been recently resolved on the development branch, if you can try things with the latest (git update), that would be great.

The released version, 1.7.1 is not affected, this was a consequence of upgrading the CLI during the development branch.



Patrick Schirch

unread,
Sep 7, 2014, 1:50:45 PM9/7/14
to ansible...@googlegroups.com
Ansible >> ansible 1.8 (devel 8cc3543918) last updated 2014/09/07 11:14:49 (GMT +200)
Git       >> 1.9.1


ssh://git@ourgitlabhost:example-group/example-role.git

ansible-galaxy install -r requirements.yml
- downloading role from ssh://git@ourgitlabhost:example-group/example-role.git
- error: failed to download the file.
- example-role was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.



Patrick Schirch

unread,
Sep 9, 2014, 5:46:52 AM9/9/14
to ansible...@googlegroups.com
Created an issue on Github ...

Michael DeHaan

unread,
Sep 9, 2014, 12:44:49 PM9/9/14
to ansible...@googlegroups.com
Thanks, I commented on it - I would use https:// for anonymous checkouts on GitHub but we can investigate.



Tomaž Štrukelj

unread,
Sep 24, 2015, 10:17:48 AM9/24/15
to Ansible Project
This still doesn't work for me , any of below :

- src: git@git.example.com:ansible/ansible-zsh.git
  scm
: git

- src: git@git.example.com/ansible/ansible-zsh.git
  scm
: git

- src: ssh://g...@git.example.com:ansible/ansible-zsh.git
  scm
: git

- src: ssh://g...@git.example.com/ansible/ansible-zsh.git
  scm
: git

- src: git+ssh://g...@git.example.com:ansible/ansible-zsh.git

- src: git+ssh://g...@git.example.com/ansible/ansible-zsh.git


All of the above produce "command git clone ... failed"

I can successfuly run "git clone g...@git.example.com:ansible/ansible-zsh.git ansible-zsh" , which gets outputed by Ansible (by using the first "src:" config above which is supposed to be incorrect syntax in the first place) :
- executing: git clone g...@git.example.com:ansible/ansible-zsh.git ansible-zsh

So Ansible seems to output here something that is not in fact executing (probably it's not using git binary)

$ ansible --version
ansible
1.9.3

I'm using Gitolite and have only ssh access , no http(s) .  It works ok with https on Github .

Tomaž Štrukelj

unread,
Oct 1, 2015, 8:30:58 AM10/1/15
to Ansible Project
Solved , my bad , used sudo instead of "sudo -E" to pass SSH_AUTH_SOCK.
And it does run git binary , the string after "executing:" is the exact command that gets executed.

vishal u

unread,
Oct 1, 2015, 8:36:37 AM10/1/15
to ansible...@googlegroups.com
write your task something like this 

# Pulls the code from a remote Git repository, - name: checkout latest web app code from github git: repo=git@repo.repo.com:repo:repo.git dest=/some/location key_file= path/to/key/file accept_hostkey=yes

Reply all
Reply to author
Forward
0 new messages