Skip to content

Fix ee_builder ansible.cfg templating error when ee_aap_version is a string#267

Open
dancorrigan1 wants to merge 2 commits into
redhat-cop:develfrom
dancorrigan1:devel
Open

Fix ee_builder ansible.cfg templating error when ee_aap_version is a string#267
dancorrigan1 wants to merge 2 commits into
redhat-cop:develfrom
dancorrigan1:devel

Conversation

@dancorrigan1

Copy link
Copy Markdown

What does this PR do?

Fixes a templating failure in the ee_builder role when ee_aap_version is
supplied as a string. The ansible.cfg.j2 template selected the galaxy API
endpoints with a numeric comparison ({% if ee_aap_version >= 2.5 %}), which
raises '>=' not supported between instances of 'str' and 'float' whenever the
value comes through as a string (e.g. "2.4") rather than the bare float in
defaults/main.yml.

How should this be tested?

This PR replaces the numeric comparison with Ansible's version test:

{% if ee_aap_version is version('2.5', '>=') %}```

The version test compares correctly whether ee_aap_version is a string or a
float, so the role no longer depends on the caller passing an exact type.
Changed in all four galaxy_server.* URL lines.

How should this be tested?
Confirm the comparison no longer errors and returns the expected result for both
string and float inputs:


$ ansible -m debug -a "msg={{ '2.4' is version('2.5','>=') }}" localhost
# => "msg": false
$ ansible -m debug -a "msg={{ 2.4 is version('2.5','>=') }}" localhost
# => "msg": false
$ ansible -m debug -a "msg={{ '2.6' is version('2.5','>=') }}" localhost
# => "msg": true
$ ansible -m debug -a "msg={{ 2.6 is version('2.5','>=') }}" localhost
# => "msg": true

End-to-end, run the ee_builder role with ee_pull_collections_from_hub: true
and ee_aap_version: "2.4" (quoted string). Before this change the
Create ansible.cfg file if requested task fails with the type error; after it,
the task renders ansible.cfg successfully, using the legacy
/api/galaxy/content/... endpoints for versions below 2.5 and the
/pulp_ansible/galaxy/... endpoints for 2.5+.

# Is there a relevant Issue open for this?
Yes

Provide a link to any open issues that describe the problem you are solving.
resolves #[number]
resolves #266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant