AAP 2.5 containerized installation fails with Collection <collection-name-and-version> already found in destination repo

Solution In Progress - Updated -

Environment

  • Red Hat Ansible Automation Platform Containerized installer

Issue

  • While rerunning the AAP 2.5 Containerized installer it fails with the following error :

    {"errors": [
    {"code": "not_found", "detail": "Collection <collection-name-and-version> already found in destination repo", "status": "404", "title": "Not found."}
    ]
    
  • The task in the role, "Upload collections to Automation Hub", should skip all collections that are already present. However, it still tries to upload collections that are already present and runs into the error.

Resolution

  • The JIRA (Ref: AAP-49013) has been raised to the Engineering team to make the changes at the installer level. Until this is implemented, the following workaround can be implemented to mitigate the above error and run the installer smoothly.

    # vi <installer_directory>/collections/ansible_collections/ansible/containerized_installer/roles/automationhub/tasks/upload_collections.yml
    
    - name: Check if collections already exists on Automation Hub
      ansible.builtin.uri:
        url: '{{ _url }}?fields=namespace,name,version&limit=200'              <<<<<< Set this limit to some more higher number
        method: GET
        headers:
          Authorization: "Basic {{ _auth | b64encode }}"
        validate_certs: true
        timeout: 60
        ca_path: '{{ _ca_tls_dir }}/extracted/pem/tls-ca-bundle.pem'
      vars:
        _auth: '{{ gateway_admin_user | default("admin") }}:{{ gateway_admin_password }}'
        _url: '{{ hostvars[groups["automationgateway"][0]]["_gateway_proxy_url"] }}/api/galaxy/pulp/api/v3/content/ansible/collection_versions'
      register: _collections
    

Root Cause

  • The task named "Check if collections already exists on Automation Hub" makes a call to the endpoint /api/galaxy/pulp/api/v3/content/ansible/collection_versions/?fields=namespace,name,version. However, it does not account for pagination and thus only returns the first 100 collections, i.e. the ones on the first page.

Diagnostic Steps

  • The following curl command can be run to verify this:

    $ curl -s -u $HUB_USER:$HUB_TOKEN https:///<hub_fqdn>/api/galaxy/pulp/api/v3/content/ansible/collection_versions/?fields=namespace,name,version | jq '.results |  length'           
    100
    
    
    $ curl -s -u $HUB_USER:$HUB_TOKEN https://<hub_fqdn>/api/galaxy/pulp/api/v3/content/ansible/collection_versions/?fields=namespace,name,version | jq '.count'
    300
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments