plugin py_pkgs.py does not adhere to normal ansible variable precedence rules

Bug #1773124 reported by Joakim Hindersson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Invalid
Undecided
Unassigned

Bug Description

Normally when overriding a variable this is done using /etc/openstack_deploy/user_variables.yml, as this follows normal ansible variable precedence rules.

This seems not to be the case for the py_pkgs plugin as it traverses the folders in it's own order and stops on first hit which will be whatever is defined in the file defaults/repo_packages/openstack_services.yml.

A temporary workaround is to fork the standard repo to make changes in default values instead of using the local overrides.

Example:
In the ocata branch of openstack-ansible we try to override the swift3 package by changing the variable swift_swift3_git_install_branch to another commit as the current one is using pike dependencies. This change is done in the user_variables.yml as would be expected by a local override.

Result:
The play runs with the default value defined in defaults/repo_packages/openstack_services.yml instead of our override in user_variables.yml.

Expected result:
The play should accept the override made in user_variables.yml.

A thought for improvement is that the script should read the folders either in reverse order and stop on first hit alternatively update the value if found in a later file instead of stopping on first hit.

Order of precedence:
3. /opt/openstack-ansible dir (lowest/default values)
2. /etc/ansible/roles
1. /etc/openstack_deploy (always used if defined)

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

The lookup is indeed behaving different as you might expect, could you check the following documentation, please?

https://docs.openstack.org/openstack-ansible/latest/user/source-overrides/index.html#overriding-other-upstream-projects-source-code

Changed in openstack-ansible:
status: New → Invalid
Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

The precedence is actually defined by the 'pkg_locations' [1] variable in group_vars, which is used when the lookup is executed [2].

The issue you hit actually was due to the fact that the lookup will not pickup an override unless the git_repo is also specified. JP has provided a link to the documentation which tries to clarify that.

[1] https://github.com/openstack/openstack-ansible/blob/465c74e75259d44c4a9a01d7fbada5c5818ab7e2/inventory/group_vars/repo_all.yml#L71-L74
[2] https://github.com/openstack/openstack-ansible/blob/465c74e75259d44c4a9a01d7fbada5c5818ab7e2/playbooks/repo-build.yml#L56-L62

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.