ansible/galaxy-issues

Role install fails with "file downloaded was not a tar.gz" for non-GitHub repo

Closed this issue · 6 comments

Installing a role from a custom git repo fails:

$ sudo ansible-galaxy -r requirements.yml install                                                                                                                                                                                          
- downloading role from https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git
 [WARNING]: - opendaylight was NOT installed successfully: the file downloaded was not a tar.gz

ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
$ cat requirements.yml                                                                                                                                                                                                                     
- name: opendaylight
  src: https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git

Installing the same role from a mirror GitHub repo works:

$ sudo ansible-galaxy -r requirements.yml install                                                                                                                                                                                          
- extracting opendaylight to /etc/ansible/roles/opendaylight
- opendaylight was installed successfully
$ cat requirements.yml                                                                                                                                                                                                                     
- name: opendaylight
  src: https://github.com/opendaylight/integration-packaging-ansible-opendaylight.git
$ ansible-galaxy --version                                                                                                                                                                                                                 
ansible-galaxy 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

@dfarrell07

I don't think ansible-galaxy is able to follow the redirect that's happening. That's my guess anyway.

When I put they following into my browser:

https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git

I get redirected to:

https://github.com/opendaylight/integration-packaging-ansible-opendaylight.git

And using the second URL, it installs the role as expected, which is what you're seeing as well.

The first URL points to gerrit, which I'm not familiar with. I know it has to do with code reviews, but I have no experience using it. Is there an archive that comes out of gerrit or something that doesn't redirect?

@chouseknecht

I can do a git clone of that repo

$ git clone https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git                                                                                                                                       
Cloning into 'ansible-opendaylight'...
remote: Total 540 (delta 0), reused 540 (delta 0)
Receiving objects: 100% (540/540), 87.92 KiB | 0 bytes/s, done.
Resolving deltas: 100% (269/269), done.
Checking connectivity... done.
$ ls ansible-opendaylight                                                                                                                                                                                                              
CONTRIBUTING.md  examples  files  handlers  LICENSE  meta  README.markdown  requirements.txt  requirements.yml  tasks  templates  tox.ini  vars

And it's the HTTPS clone URL recommended on the Gerrit/GitWeb summary page for the repo.

I can't recreate the redirect you mentioned and find it unlikely as it's a one-way interaction (Gerrit knows nothing about GitHub, GitHub watches Gerrit).

Gerrit is like GitHub for groups that require open source tooling (Linux Foundation projects in this case).

Yes, I can do a git clone of it as well. The other day it was redirecting, but now it doesn't seem to be.

This is working for me:

$ ansible-galaxy install -p . git+https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git

Changing requirements.yml to the following also works:

- name: opendaylight
  src: git+https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git

And then run the install...

$ ansible-galaxy install -p . -r requirements.yml
- extracting opendaylight to /Users/chouseknecht/opendaylight
- opendaylight was installed successfully

So maybe the syntax in your requirements.yml is off. Instead of src:, it should be src: git+.

@chouseknecht

Prefixing the URL with git+ makes things work as expected.

Explicitly specifying scm also works:

- name: opendaylight
  src: https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git
  scm: git

I wonder why ansible-galaxy doesn't need this hint when cloning from GitHub? Could it be improved to automatically do the right thing for other tools, like Gerrit?

Thanks for the help!

@dfarrell07

Perhaps ansible-galaxy could be modified to do the right thing. Not sure. Pull requests welcome :-)

Closing this, since I think we figured out the issue.

Thanks!