Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name variable no longer inherited #34272

Closed
mscherer opened this issue Dec 28, 2017 · 4 comments
Closed

Name variable no longer inherited #34272

mscherer opened this issue Dec 28, 2017 · 4 comments
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@mscherer
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

core

ANSIBLE VERSION
CONFIGURATION

Nothing special

SUMMARY

So I do use variable inheritence quite a lot, especially to define roles that pull others roles with specific change. However, I found that if a variable is called name, this is no longer inherited.

I bisected to that commit:
0d35a69

I suspect the "inherit=False" is the root cause of my issue. I did verify that changing the name of the variable do fix the issue (e.g., it only manifests for 'name', not for 'name2'.

I do use this construct for example on https://github.com/gluster/gluster.org_ansible_configuration/blob/master/playbooks/deploy_proxy_vm.yml with a common set of param being set by using meta and dependencies on https://github.com/gluster/gluster.org_ansible_configuration/blob/master/roles/guest_proxy_rht/meta/main.yml

STEPS TO REPRODUCE

play.yml

---
- hosts: 127.0.0.1
  roles:
  - role: foo
    name: foo1

roles/foo/meta/main.yml

---
dependencies:
- role: foo2

roles/foo2/tasks/main.yml

---
- name: "Test if {{ name }} is defined"
  debug:
    var: name
EXPECTED RESULTS

I expected this message to be displayed:

TASK [foo2 : Test if {{ name }} is defined] *************************************************************
ok: [127.0.0.1] => {
    "name2": "foo1"
}
ACTUAL RESULTS

This message is displayed

TASK [foo2 : Test if {{ name }} is defined] *************************************************************

ok: [127.0.0.1] => {
    "name": "VARIABLE IS NOT DEFINED!"
}
@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug_report needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 28, 2017
@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Dec 28, 2017
@bcoca
Copy link
Member

bcoca commented Jan 2, 2018

Possible Misunderstanding

Hi!

Thanks very much for your submission to Ansible. It sincerely means a lot to us.

We believe the ticket you have filed is being somewhat misunderstood, as one thing works a little differently than stated.

This was actually a bug fix, role name is NOT a variable but a property of the role that is aliased/overlaps with the role property. If you need a 'name' variable, use the vars: property to define it.

In the future, this might be a topic more well suited for the user list, which you can also post here if you'd like some more help with the above.

Thank you once again for this and your interest in Ansible!

@bcoca bcoca closed this as completed Jan 2, 2018
@mscherer
Copy link
Contributor Author

mscherer commented Jan 3, 2018

That's still a behavior change that break existing playbook, and so should be documented at minima.

@mscherer mscherer reopened this Jan 3, 2018
@mscherer
Copy link
Contributor Author

mscherer commented Jan 3, 2018

Looking at https://docs.ansible.com/ansible/devel/playbooks_reuse_roles.html this is not documented or anything. So pushing a change as a bugfix for a non documented behavior that result in breakage of users playbooks is not really great, I would at least expect the usual deprecation cycle if that's the way we want to go, and have something somewhere in CHANGELOG.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
mscherer added a commit to gluster/gluster.org_ansible_configuration that referenced this issue Jun 18, 2018
@samdoran
Copy link
Contributor

Role docs have been updated to use vars. There is a porting guide entry that addresses this change in behavior.

@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

5 participants