Error while installing collections from Red Hat Automation Hub

Solution Verified - Updated -

Environment

  • Red Hat Ansible Automation Platform (Ansible Automation Platform) 2.1.2 and later;
  • Ansible Automation Controller;
  • Ansible Automation Hub;
  • ansible-galaxy;

Issue

  • While trying to install collections from private Automation Hub, it fails with the following error:

    ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
    * ansible.tower:3.8.6 (direct request)
    ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
    * redhat.satellite:* (direct request)
    

Resolution

There are two causes of this error and 2 resolutions:

  • There really is a dependency resolution error. Some collections may have pre-release versions or dependencies that are pre-release. These are not downloaded by default and the above error is displayed. In this case, follow the steps below:

    1. Check the version that is being downloaded and try an earlier release or specify a specific release for example:

      ansible-galaxy collection install redhat.satellite:==5.4.0
      
    2. Try using the --pre parameter to allow pre-release versions of collections.

      ansible-galaxy collection install redhat.satellite --pre 
      
  • The Ansible Automation Hub token is expired and needs refreshing:

    1. Refresh the Automation Hub Token by using the following command to refresh the token:

      curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id="cloud-services" -d refresh_token="{{ user_token }}" --fail --silent --show-error --output /dev/null
      
    2. Update the AAP credentials.In case a new token is created (rather than refreshing the old one), update the token in the configuration.

    3. When using ansible-galaxy directly or the global configuration - update the ansible.cfg file and make sure that there are no quotes around the token in /etc/ansible/ansible.cfg

      [galaxy]
      server_list = published, galaxy_root
      
      [galaxy_server.galaxy_root]
      url=https://galaxy.ansible.com
      
      [galaxy_server.published]
      url=https://console.redhat.com/api/automation-hub/content/published/
      auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
      token=eyJhbGciOi....lLKjdf
      # ----^---- CORRECT -----^
      
      # token="eyJhbGciOi....lLKjdf"
      # ------^---- INCORRECT -----^
      # This will also cause the resolve dependency error
      
    • When storing the token in Ansible Automation Platform Controller:

      • Navigate to Resources -> Credentials;
      • Select the appropriate Ansible Galaxy/Automation Hub API Token entry;
      • Select the Edit button;
      • Modify the token by clicking on the button next to the entry;
      • Copy new token into the textbox and select Save;
    • When using a Private Automation Hub in Ansible Automation Platform Environment:

      • Navigate to Collections -> Remotes;
      • Select the appropriate Remote for the collection set;
      • Select the Edit button;
      • Modify the token by clicking on the button next to the entry;
      • Copy new token into the textbox and select Save;
    • When using the token in an Ansible vault file:

      • Decrypt the vault file;
      • Update the token entry in the file;
      • Encrypt the vault file again and update repositories;
  • Make sure that ansible.cfg file points to the correct repository;

Root Cause

  • There may be pre-release elements in the collection tree.
  • The token will expire after 30 days of inactivity.

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