ansible / galaxy

Legacy Galaxy still available as read-only on https://old-galaxy.ansible.com - looking for the new galaxy -> https://github.com/ansible/galaxy_ng
Apache License 2.0
854 stars 329 forks source link

Cannot import role to Galaxy after changing default branch from 'master' to 'main' #2535

Closed artis3n closed 3 years ago

artis3n commented 4 years ago

Bug Report

SUMMARY

I am trying to release a new version of https://github.com/artis3n/ansible-role-tailscale. I used to use master, but moved over to main as the default branch.

Galaxy fails to import the role - it is looking for a master branch. I am not sure whether this is configurable when I first sync the repo to Galaxy, but it does not look like I can force a re-sync of the role without deleting the role from Galaxy, which I do not want to do.

Starting import: task_id=737380, repository=artis3n/ansible-role-tailscale 

Task "737380" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/artis3n/ansible-role-tailscale.git', '/var/tmp/galaxy/imports/tmppmsnb2cx']' returned non-zero exit status 128. 
STEPS TO REPRODUCE
  1. Create a minimal ansible role using master as the default branch.
  2. Through the Galaxy UI, select "My Content" -> "Add Content" -> "Import Role from GitHub."
  3. Change the default branch of the repo to main.
  4. Release a higher version of the role on GitHub.
  5. Through the Galaxy UI, select "My Content" -> "Import" next to your role
  6. Observe that the import fails.
EXPECTED RESULTS

Galaxy always uses the default branch on the repo, or provides a method to force a re-sync to update the default branch stored by Galaxy for the role's repo.

ACTUAL RESULTS

Galaxy looked for master to exist on the repo and the role failed to import and update on Ansible Galaxy.

Starting import: task_id=737380, repository=artis3n/ansible-role-tailscale 

Task "737380" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/artis3n/ansible-role-tailscale.git', '/var/tmp/galaxy/imports/tmppmsnb2cx']' returned non-zero exit status 128. 
artis3n commented 4 years ago

I fixed this by deleting the role and re-importing it from GitHub. I have lost all downloads metrics :(

xanmanning commented 4 years ago

I've also found this issue, changing branches from master to main will break import into galaxy.ansible.com

I'm keen not to have to re-import the role, it seems a bit of a faff.

Starting import: task_id=745477, repository=PyratLabs/ansible-role-k3s 

Task "745477" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/PyratLabs/ansible-role-k3s.git', '/var/tmp/galaxy/imports/tmp_g6r_d13']' returned non-zero exit status 128. 
chouseknecht commented 3 years ago

Try setting galaxy_info.github_branch to the branch name in the metadata file.

xanmanning commented 3 years ago

I can confirm this works for me @chouseknecht - thank you.

artis3n commented 3 years ago

I will forever mourn my lost download metrics, but perfect, thanks @chouseknecht . Is there documentation for that setting I missed, or was that added?

dallinb commented 3 years ago

Hi @artis3n It is mentioned in https://galaxy.ansible.com/docs/contributing/creating_role.html#role-metadata

artis3n commented 3 years ago

Woops, definitely read straight over that. Thanks for linking.

Normo commented 3 years ago

Hi folks We are facing exactly the same problem when trying to import https://github.com/hifis-net/ansible-role-gitlab (hifis.gitlab) into Galaxy. As recommended by @chouseknecht I set galaxy_info.github_branch to main (https://github.com/hifis-net/ansible-role-gitlab/commit/cc4526335192126648686628e3191d7fe48b7e87).

But Galaxy still uses the non-existent master branch:

Starting import: task_id=783214, repository=hifis-net/ansible-role-gitlab 

Task "783214" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/hifis-net/ansible-role-gitlab.git', '/var/tmp/galaxy/imports/tmpfl4v_t8d']' returned non-zero exit status 128. 

Are we doing anything wrong here?

dallinb commented 3 years ago

I temporarily recreated the master branch from main. Ensured that got ingested by Ansible Galaxy (which then picked up the new config change setting the branch to main). When you confirm that Galaxy is correctly ingesting from main you can delete the master branch permanently.

Normo commented 3 years ago

@dallinb Thank you for your support. Unfortunately Galaxy still tries to import the master branch. I also recreated the master branch and triggered an import which worked fine. But after removing the master branch, the import failed again:

Starting import: task_id=783870, repository=hifis-net/ansible-role-gitlab 

Task "783870" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/hifis-net/ansible-role-gitlab.git', '/var/tmp/galaxy/imports/tmp70hgo983']' returned non-zero exit status 128. 

Is there anything else we can try?

bittner commented 3 years ago

I can confirm the behavior @Normo has reported. I have the same setup as them for the painless.software role, explicitly pointing Galaxy to the main branch (with the same configuration on master for transitioning).

When triggering an import from the Galaxy Web UI imports continue to pull from master. Consequently, as soon as the master branch is deleted imports fail.

bittner commented 3 years ago

@chouseknecht Could this behavior ^^^ be, specifically with the painless author, maybe related to the fact that the GitHub namespace is not the same as the one on Ansible Galaxy? Remember, you configured that manually on my request (#1414).

albertvaka commented 2 years ago

This also happens to datadog.datadog when we rename master to main even after we have changed the metadata. Any chance someone can help us with that?

albers commented 2 years ago

Same with hamburger_software.vmware_ubuntu_cloud_image. Both branches exist and point to the same commit with the updated metadata. But galaxy keeps importing from master. I had to revert.

thermistor commented 2 years ago

From td2's comment you can import with a different branch via the command line. Get your token from your galaxy preferences.

ansible-galaxy role import -vvv --branch main --token SECRET github_user github_repo
staticdev commented 1 year ago

@thermistor this is the best solution so far. You just put this argument and everything will be corrected on Ansible Galaxy.. no need to recreate master branch!

@artis3n this way you would not have lost anything.

artis3n commented 1 year ago

2 years later, I agree there are better options available :)

bittner commented 1 year ago

More than 1.5 years later I'm still stuck with the same problem. Probably related to the custom configuration of my account. Any help possible, @chouseknecht?

bittner commented 1 year ago

This used to work with just the main branch for roughly the last year (without an additional master branch) until the new Galaxy site was released a few days day ago. Now there seems to be a regression. The following error is reported:

$ ansible-galaxy install painless.software
Starting galaxy role install process
- downloading role 'software', owned by painless
- downloading role from https://github.com/painless/ansible-role-software/archive/master.tar.gz
 [ERROR]: failed to download the file: HTTP Error 404: Not Found
[WARNING]: - painless.software was NOT installed successfully.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

Obviously, the repository painless/ansible-role-software doesn't exist on GitHub. It should be painless-software/ansible-role-software, which suggests that Galaxy NG enforces the default mapping (Ansible namespace = GitHub namespace) again.

I reported this with other details in the new Ansible Community forum.