artis3n / ansible_galaxy_collection

Deploy a Collection to Ansible Galaxy.
MIT License
89 stars 8 forks source link

[feat]: Ability to publish to Automation Hub or alternate galaxies #300

Open ahuffman opened 2 years ago

ahuffman commented 2 years ago

image Looks like the above image.

ahuffman commented 2 years ago

I don't have all the details yet, but I think you can get a token like you can on Galaxy, but it may require user/pass options.

artis3n commented 2 years ago

Thanks for filing! I'll take a look, but yeah any details you can provide on how RedHat works here would be useful.

artis3n commented 2 years ago
ahuffman commented 2 years ago

I got an example of what this looks like finally. Essentially you get a separate url to push to, an auth url, and a separate token. So if you provide those as add'l config params that would be all that's needed.

      - name: Upload to Ansible Automation Hub
        run: |
          cat << EOF > ansible.cfg
          [galaxy]
          server_list = automation_hub
          [galaxy_server.automation_hub]
          url=https://console.redhat.com/api/automation-hub/content/inbound-mycompany/
          auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
          token=$AAP_KEY
          EOF
          ansible-galaxy collection publish ./mycollection*.tar.gz
artis3n commented 2 years ago

Token is already handled by the api_key input parameter so the need is to provide an optional path to set the --server API_SERVER parameter for ansible-galaxy. ansible-galaxy collection publish does not extend an auth_url flag so that looks Redhat-specific, need to understand how to best set that.

https://access.redhat.com/documentation/en-us/red_hat_ansible_automation_platform/2.1/html/getting_started_with_automation_hub/proc-configure-automation-hub-server suggests auth_url is optional, depending on the automation hub server in question. So that should be supported but is not required for all automation hub targets.

@ahuffman I'm not familiar with navigating around RedHat's docs - is there an environment variable we can substitute for the auth_url ansible.cfg value? https://docs.ansible.com/ansible/latest/reference_appendices/config.html describes env var alternatives for default ansible.cfg values but auth_url isn't in there so not sure if an env var version exists. That would be my preferred way of implementing this support.