redhat-cop / infra.aap_configuration

A collection of roles to manage Ansible Automation Platform 2.5+ with code
https://galaxy.ansible.com/infra/aap_configuration
GNU General Public License v3.0
276 stars 141 forks source link

Lookup with dynamic names throw error with ansible 2.15.8 #741

Closed bogdanmuresan closed 6 months ago

bogdanmuresan commented 11 months ago

Summary

With latest AAP installation (Ansible Automation Platform 2.4.3 - controller 4.4.8) we get following error: We could also replicate it by updating the execution env image, to one that has ansible [core 2.15.8] It works on ones with ansible [core 2.15.5]

TASK [infra.controller_configuration.object_diff : Check if the connection is to an Ansible Tower or to Automation Platform] ***
fatal: [localhost]: FAILED! => {"msg": "the field 'args' has an invalid value ({'is_aap': \"{{ lookup(controller_api_plugin, 'ping', host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs).version is version('4.0.0', '>=') }}\"}), and could not be converted to an dict.The error was: unmarshallable object\n\nThe error appears to be in '/runner/requirements_collections/ansible_collections/infra/controller_configuration/roles/object_diff/tasks/main.yml': line 53, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Check if the connection is to an Ansible Tower or to Automation Platform\"\n  ^ here\n"}
  "msg": "the field 'args' has an invalid value ({'is_aap': \"{{ lookup(controller_api_plugin, 'ping', host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs).version is version('4.0.0', '>=') }}\"}), and could not be converted to an dict.The error was: unmarshallable object\n\nThe error appears to be in '/runner/requirements_collections/ansible_collections/infra/controller_configuration/roles/object_diff/tasks/main.yml': line 53, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Check if the connection is to an Ansible Tower or to Automation Platform\"\n  ^ here\n"

pointing the issue to the code here: https://github.com/redhat-cop/controller_configuration/blob/2.5.2/roles/object_diff/tasks/main.yml#L55

After doing some debugging, I could only make it work by replacing the "controller_api_plugin" variable in the lookup with the actual value - 'awx.awx.controller_api'.

next failure is

fatal: [localhost]: FAILED! => {
    "msg": "the field 'args' has an invalid value ({'__projects_difference': '{{ query(controller_role_plugin, api_list=__controller_api_projects, compare_list=controller_projects, with_present=include_present_state, set_absent=true) | flatten }}'}), and could not be converted to an dict.The error was: unmarshallable object\n\nThe error appears to be in '/runner/requirements_collections/ansible_collections/infra/controller_configuration/roles/object_diff/tasks/projects.yml': line 19, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Find the difference of Project between what is on the Controller versus CasC on SCM\"\n  ^ here\n"
}

same unmarshallable error, this time with query.

Issue Type

Ansible, Collection, Controller details

ansible --version
 podman run --rm -it --entrypoint /bin/bash registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel8:latest
bash-4.4# ansible --version
ansible [core 2.15.8]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Sep 22 2023, 17:58:34) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
ansible-galaxy collection list

Controller version
4.4.8
Ansible Automation Platform 2.4.3

OS / ENVIRONMENT

AAP

Desired Behavior

Actual Behavior

Please give some details of what is actually happening. Include a minimum complete verifiable example with:

STEPS TO REPRODUCE

simon-mags commented 9 months ago

Can confirm we are seeing this same lookup error with the invalid "is_aap" field. We are running Ansible Automation Platform 2.4 with Controller 4.4.5.

We dropped the Execution Environment back to 1.0.0.-464 which runs Ansible Core 2.15.5 as pointed out by @bogdanmuresan already and then we were able to run the filetree_create commands etc as normal

djdanielsson commented 8 months ago

we will have to look into this more, we cannot use FQCN in this case because some users use awx.awx and others use ansible.controller

jonesalexr commented 8 months ago

I confirm i see this as well running AWX 23.2 to 23.8. I can not run the filetree_create role on any ansible core newer than 2.15.6. I just target an older EE "awx-ee:23.4.0" until this is resolved.

ecchong commented 8 months ago

I found that using a debug task to perform a useless lookup before the filetree_create role can temporary suppress the problem using current EE

- name: TODO - work around
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.controller.controller_api', 'ping',
                    host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs) }}"
adonisgarciac commented 8 months ago

This issue comes from this change from ansible 2.15.7: https://github.com/ansible/ansible/issues/82708.

It seems it is solved for 2.16 https://github.com/ansible/ansible/pull/82759/files

adonisgarciac commented 8 months ago

The fix was backported to 2.14 and 2.15. I think we can close this issue because it is a bug in Ansible Core. It was solved and it will be working property again in next releases. Meanwhile, I suggest to use ansible 2.15.6 while it is possible.

https://github.com/ansible/ansible/pull/82791 https://github.com/ansible/ansible/pull/82790