chocolatey / chocolatey-ansible

The Chocolatey module collection for Ansible
GNU General Public License v3.0
49 stars 30 forks source link

(#112) Fix automation hub publishing #127

Closed vexx32 closed 1 year ago

vexx32 commented 1 year ago

Description Of Changes

Motivation and Context

ansible-galaxy doesn't support publishing to multiple servers at once

Instead, we need to specify each server, along with their api keys.

Testing

I tested this configuration by:

  1. from the build folder, vagrant up
  2. vagrant ssh choco_ansible_server
  3. vim chocolatey/galaxy.yml
  4. Edit the file to include a valid version number (I used 1.0.0)
  5. Save and quit vim (:x)
  6. touch ansible-custom.config
  7. vim ansible-custom.config
  8. Paste in the content of the ansible.cfg file from this PR
  9. Save and quit vim
  10. Export necessary environment variables:
    export ANSIBLE_CONFIG=/home/vagrant/ansible-custom.cfg
    export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN=junktokenvalue
  11. Attempt to build and upload the collection with the nonsense auth token:
    cd chocolatey
    ansible-galaxy collection build
    ansible-galaxy collection publish *.tar.gz --server automation_hub
  12. You should get a 401 (Unauthorized) error
  13. For a fully conclusive test, I also attempted to upload an already-existing version of the collection using a valid auth key.
  14. Doing so produced the following error:
    Publishing collection artifact '/home/vagrant/chocolatey/chocolatey-chocolatey-1.4.0.tar.gz' to automation_hub https://cloud.redhat.com/api/automation-hub/content/inbound-chocolatey/
    ERROR! Error when publishing collection to automation_hub (https://cloud.redhat.com/api/automation-hub/content/inbound-chocolatey/) (HTTP Code: 400, Message: Artifact already exists Code: invalid)

Operating Systems Testing

N/A

Change Types Made

Change Checklist

Related Issue

Fixes #112

Windos commented 1 year ago

Thanks for sorting this out, @vexx32!