RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1485074 - [RFE]: Add conditional or remove include_vars within role as include_vars is too high on variable precedence
Summary: [RFE]: Add conditional or remove include_vars within role as include_vars is ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rhel-system-roles
Version: 7.4
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Thomas Haller
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-24 23:32 UTC by James Marshall
Modified: 2020-12-14 09:42 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-10-19 15:21:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Replication playbook example (209 bytes, text/x-vhdl)
2017-08-24 23:32 UTC, James Marshall
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:2970 0 normal SHIPPED_LIVE rhel-system-roles bug fix update 2017-10-19 18:54:31 UTC

Description James Marshall 2017-08-24 23:32:39 UTC
Created attachment 1317934 [details]
Replication playbook example

Description of problem:
The include_vars module is too high on the variable precedence list as documented here: http://docs.ansible.com/ansible/latest/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable and significantly prevents user customization. Users are unable to define variables for the role at the top level playbook and can only overwrite with extra vars or facts.

Version-Release number of selected component (if applicable):
7.4

How reproducible:
Top level playbook which calls the network role attached.

Steps to Reproduce:
1. `ansible-playbook -i some_inventory network-var.yml -e nodes="some_group_or_host"`

Actual results:
At the role "tasks" level, the following task overwrites "something_else" for network_provider

```
- name: Set version specific variables
  include_vars: "{{ item }}"
  with_first_found:
      - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
      - "{{ ansible_distribution }}.yml"
      - "{{ ansible_os_family }}.yml"
      - "default.yml"
```

Expected results:
"something_else" is retained

Additional info:
This is important for network role users on RHEL7 who are still using initscripts over NetworkManager. The only way around this requires custom modification of the role and should be more accessible.

Comment 3 Pavel Cahyna 2017-09-12 16:24:53 UTC
I can't really reproduce your problem with network_provider. If I set it to "something_else", the role complains that "unsupported provider something_else". IMO this is correct. Yes, include_vars module is high on the variable precedence list, but the files included this way do not actually define "network_provider" and therefore they do not clobber it. It clobbers network_provider_default and network_packages, but I suppose those are not intended to be customized by the user.

To debug such issues, I suggest importing the role using tasks:include_role: instead of roles: and use the debug module before and after. You should see that the network role changes network_provider_default but not network_provider.

  tasks:
    - name: debug var before
      debug:
        var: network_provider
    - name: net role
      include_role:
        name: linux-system-roles.network
      ignore_errors: True
    - name: debug var after
      debug:
        var: network_provider

Comment 8 Thomas Haller 2017-09-21 09:23:15 UTC
the files in vars [1] do not define "network_provider" at all. Hence, the original comment is incorrect:

> At the role "tasks" level, the following task overwrites "something_else" for 
> network_provider

Which can also be seen with -vvvv:

  fatal: [test-server]: FAILED! => {
      "changed": false, 
      "failed": true, 
      "invocation": {
          "module_args": {
              "connections": [
  ...
              "ignore_errors": "False", 
              "provider": "initscripts"
          }
      }, 


What however happens is that other variables like network_service_name and network_packages are overwritten. Which is wrong and needs fixing


[1] https://github.com/linux-system-roles/network/tree/a4ebfadded1c4e96e3a7b5e71f7cfc2da46ee1d6/vars

Comment 9 Thomas Haller 2017-09-21 10:51:16 UTC
Please review https://github.com/linux-system-roles/network/pull/14

Comment 16 errata-xmlrpc 2017-10-19 15:21:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2970


Note You need to log in before you can comment on or make changes to this bug.