galaxy: Cannot import role to Galaxy after changing default branch from 'master' to 'main'

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. 

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 19 (1 by maintainers)

Most upvoted comments

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.

@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?

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

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. 

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