redhat-cop / aap_utilities

Ansible Collection for automated deployment of AAP and other objects for general use
https://galaxy.ansible.com/infra/aap_utilities
GNU General Public License v3.0
79 stars 49 forks source link

aap_setup_install assumes dictionaries in aap_setup_prep_inv_nodes var #197

Closed jon4hz closed 8 months ago

jon4hz commented 1 year ago

Hi, quick follow up to #192 because I figured out what caused my issue.

https://github.com/redhat-cop/aap_utilities/blob/a97c522059926da73ae74c01c3efe29c22426152/roles/aap_setup_install/defaults/main.yml#L51

This should probably be something like {{ aap_setup_prep_inv_nodes['automationcontroller'] | first }}. Same goes for ah_hostname and eda_hostname - or you keep the role as it is and adjust the example in the readme :)

sean-m-sullivan commented 1 year ago

Can you point to me where in the documentation it shows dicts, as we would need to change that, I've looked at the aap setup install, download, and prep, and I see lists used in the examples. Its never meant to be a dict. ever.

Like this: https://github.com/redhat-cop/aap_utilities/tree/devel/roles/aap_setup_prepare#example-inventory-variables

jon4hz commented 1 year ago

It doesn't show dicts in any documentation. The issue is that the defaults from the aap_setup_install assume dicts.

https://github.com/redhat-cop/aap_utilities/blob/a97c522059926da73ae74c01c3efe29c22426152/roles/aap_setup_install/defaults/main.yml#L51

https://github.com/redhat-cop/aap_utilities/blob/a97c522059926da73ae74c01c3efe29c22426152/roles/aap_setup_install/defaults/main.yml#L63

https://github.com/redhat-cop/aap_utilities/blob/a97c522059926da73ae74c01c3efe29c22426152/roles/aap_setup_install/defaults/main.yml#L69

See the code snippets above. You're calling the keys() method on aap_setup_prep_inv_nodes['automationcontroller'] which will throw the error: 'list object' has no attribute 'keys'.

This behavior was introduced by #133 as "fix hostnames".

ericzolf commented 8 months ago

They should all be dictionaries and they can all be dictionaries, in order to allow for host variables in the ini files (not the nicest way to do it, but rather common for setup.sh). The truth was and is in aap_setup_prepare: "aap_setup_prep_inv_nodes [...] a dictionary of dictionaries, the first level key is the inventory group name, the 2nd level key is the hostname with the value being its inventory host variables in INI-format".

I'll close both #196 and #197 with a documentation update.