Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
artis3n opened this issue Oct 30, 2020 · 19 comments

Comments

@artis3n
Copy link

artis3n commented Oct 30, 2020

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
Copy link
Author

artis3n commented Nov 6, 2020

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

@xanmanning
Copy link

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
Copy link
Contributor

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

@xanmanning
Copy link

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

@artis3n
Copy link
Author

artis3n commented Dec 16, 2020

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
Copy link

dallinb commented Dec 24, 2020

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

@artis3n
Copy link
Author

artis3n commented Dec 24, 2020

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

@artis3n artis3n closed this as completed Dec 24, 2020
@Normo
Copy link

Normo commented Feb 22, 2021

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 (hifis-net/ansible-role-gitlab@cc45263).

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
Copy link

dallinb commented Feb 22, 2021

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
Copy link

Normo commented Feb 23, 2021

@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
Copy link

bittner commented Mar 20, 2021

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
Copy link

bittner commented Mar 20, 2021

@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
Copy link

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
Copy link

albers commented Feb 1, 2022

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
Copy link

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
Copy link

staticdev commented Dec 4, 2022

@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
Copy link
Author

artis3n commented Dec 4, 2022

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

@bittner
Copy link

bittner commented Dec 4, 2022

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
Copy link

bittner commented Oct 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants