How to resolve the error "The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute '_automationhub_main_host' " while installing the Ansible Automation Platform 2.x ? ?

Solution Verified - Updated -

Environment

  • Red Hat® Ansible Automation Platform 2.x

Issue

  • While installing Ansible Automation Platform, the installer fails with the following error:

    TASK [ansible.automation_platform_installer.automationcontroller : set_fact] ***
    ^[[1;30mtask path: /opt/ansible-automation-platform-setup-bundle-2.3-1.3/collections/ansible_collections/ansible/automation_platform_installer/roles/automationcontroller/tasks/post_install_setup.yml:2^[[0m
    ^[[0;31mfatal: [controller]: FAILED! => {^[[0m
    ^[[0;31m    "msg": "The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute '_automationhub_main_host'. 'ansible.vars.hostvars.HostVarsVars object' has no attribute '_automationhub_main_host'\n\nThe error appears to be in '/opt/ansible-automation-platform-setup-bundle-2.3-1.3/collections/ansible_collections/ansible/automation_platform_installer/roles/automationcontroller/tasks/post_install_setup.yml': line 2, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- block:\n    - set_fact:\n      ^ here\n"^[[0m
    ^[[0;31m}^[[0m
    
    

Resolution

  • Replace the following task inside installer directory ./ansible-automation-platform-setup-bundle-2.3-1.3/collections/ansible_collections/ansible/automation_platform_installer/roles/automationcontroller/tasks/post_install_setup.yml

    From:

      - set_fact:
          _hub_host: "{{ hostvars[groups['automationhub'][0]]['_automationhub_main_host'] + '/' }}"
    

    To:

    - set_fact:
          _hub_host: "{{ hostvars[groups['automationhub'][0]]['automationhub_main_host'] + '/' }}" 
    

Diagnostic Steps

  • Automation hub installation fails with the following error.

    TASK [ansible.automation_platform_installer.automationhub : Create temporary directory for collections] ***
    fatal: [autohub.example.com]: FAILED! => {"msg": "The conditional check '_collection_tarball_check.results | selectattr('stat.exists', 'true') | length' failed. The error was: no test named 'true'\n\nThe error appears to be in '/var/installs/ansible-automation-platform-setup-bundle-2.4-7.1-x86_64/collections/ansible_collections/ansible/automation_platform_installer/roles/automationhub/tasks/seed_collection_for_repository.yml': line 88, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n    - block:\n        - name: Create temporary directory for collections\n          ^ here\n"}
    

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