Summary
The ee_builder role fails when rendering the ansible.cfg file because the
ansible.cfg.j2 template compares ee_aap_version numerically:
{% if ee_aap_version >= 2.5 %}. When ee_aap_version is supplied as a string
(e.g. "2.4", which is natural since YAML/quoted values and many var sources
produce strings), Python cannot compare a str to the float literal 2.5,
and templating aborts with:
'>=' not supported between instances of 'str' and 'float'
The default value in defaults/main.yml is the bare float 2.4, so the role
works out of the box, but any consumer passing the version as a string hits the
error. The fix is to use Ansible's version test, which compares safely
regardless of whether the value is a string or a float.
Issue Type
Ansible, Collection, Docker/Podman details
ansible --version
ansible [core 2.20.5]
ansible-galaxy collection list
# infra.ee_utilities 4.4.0
podman --version
podman version 4.x
ansible installation method: pip
OS / ENVIRONMENT
Control/build host: RHEL/UBI-based container, Python 3.12
AAP target: 2.6
Desired Behavior
The Create ansible.cfg file if requested task should render ansible.cfg
successfully whether ee_aap_version is provided as a string ("2.4") or a
float (2.4), selecting the legacy /api/galaxy/content/... endpoints for
versions below 2.5 and the /pulp_ansible/galaxy/... endpoints for 2.5+.
Actual Behavior
Templating of ansible.cfg.j2 raises a TypeError and the build fails.
fatal: [localhost]: FAILED! => {
"msg": "AnsibleError: Unexpected templating type error occurred on (...
url=https://{{ ee_ah_host }}{% if ee_aap_version >= 2.5 %}/pulp_ansible/galaxy/rh-certified/{% else %}/api/galaxy/content/rh-certified/{% endif +%}
...): '>=' not supported between instances of 'str' and 'float'."
}
File "<template>", line 16, in root
TypeError: '>=' not supported between instances of 'str' and
```console (error)
STEPS TO REPRODUCE
Run the ee_builder role with ee_pull_collections_from_hub: true and
ee_aap_version set as a quoted string.
- hosts: localhost
gather_facts: false
tasks:
- name: Build EE
ansible.builtin.import_role:
name: infra.ee_utilities.ee_builder
ee_aap_version: "2.4" # string, not float -> triggers the bug
ee_pull_collections_from_hub: true
ee_ah_host: hub.example.com
ee_ah_token: "{{ my_token }}"
ee_list:
Summary
The
ee_builderrole fails when rendering theansible.cfgfile because theansible.cfg.j2template comparesee_aap_versionnumerically:{% if ee_aap_version >= 2.5 %}. Whenee_aap_versionis supplied as a string(e.g.
"2.4", which is natural since YAML/quoted values and many var sourcesproduce strings), Python cannot compare a
strto the float literal2.5,and templating aborts with:
'>=' not supported between instances of 'str' and 'float'The default value in
defaults/main.ymlis the bare float2.4, so the roleworks out of the box, but any consumer passing the version as a string hits the
error. The fix is to use Ansible's
versiontest, which compares safelyregardless of whether the value is a string or a float.
Issue Type
Ansible, Collection, Docker/Podman details
ansible installation method: pip
OS / ENVIRONMENT
Control/build host: RHEL/UBI-based container, Python 3.12
AAP target: 2.6
Desired Behavior
The Create ansible.cfg file if requested task should render ansible.cfg
successfully whether ee_aap_version is provided as a string ("2.4") or a
float (2.4), selecting the legacy /api/galaxy/content/... endpoints for
versions below 2.5 and the /pulp_ansible/galaxy/... endpoints for 2.5+.
Actual Behavior
Templating of ansible.cfg.j2 raises a TypeError and the build fails.
STEPS TO REPRODUCE
Run the ee_builder role with ee_pull_collections_from_hub: true and
ee_aap_version set as a quoted string.
gather_facts: false
tasks:
ansible.builtin.import_role:
name: infra.ee_utilities.ee_builder
ee_aap_version: "2.4" # string, not float -> triggers the bug
ee_pull_collections_from_hub: true
ee_ah_host: hub.example.com
ee_ah_token: "{{ my_token }}"
ee_list: