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

Raise a warning when a reserved variable is set #4816

Closed
jcassee opened this issue Nov 5, 2013 · 10 comments · Fixed by #20567
Closed

Raise a warning when a reserved variable is set #4816

jcassee opened this issue Nov 5, 2013 · 10 comments · Fixed by #20567
Labels
affects_1.9 This issue/PR affects Ansible v1.9 affects_2.3 This issue/PR affects Ansible v2.3 c:vars/variable_manager feature This issue/PR relates to a feature request.

Comments

@jcassee
Copy link
Contributor

jcassee commented Nov 5, 2013

As per a list discussion, it would be nice if a warning was printed if the user tries to set a reserved variable, such as environment.

@mpdehaan
Copy link
Contributor

Classifying this as a bug report so it doesn't get lost in the list.

@mpdehaan mpdehaan added P3 and removed P3 labels Mar 19, 2014
@mpdehaan mpdehaan added P4 and removed P3 labels Apr 17, 2014
@samdaltonmaag
Copy link

+1, this had me stumped for a bit using "environment", and only figured it out after guessing it might be the case.

@bcoca bcoca added this to the v2 milestone Apr 2, 2015
@FractalizeR
Copy link

Spent several hours figuring out why a variable named environment doesn't contain what I suppose it to contain.

+1 from me.

@FractalizeR
Copy link

BTW, is there is a list of all things 'reserved'? Just not to stumble over such cases again...

@bcoca
Copy link
Member

bcoca commented May 4, 2015

not a central one, mostly we have some 'magic' internal vars and then keywords/directives for play, role and task.

@bcoca bcoca added the v2 label May 8, 2015
@bcoca bcoca removed this from the v2 milestone May 8, 2015
@bcoca bcoca modified the milestone: v2 Jun 29, 2015
@bcoca bcoca removed the v2 label Jun 29, 2015
@bcoca bcoca removed this from the v2 milestone Jul 24, 2015
@jimi-c jimi-c removed the P4 label Dec 7, 2015
@meebey
Copy link

meebey commented Jan 28, 2016

I tried to pass a variable named port from a role definition like this:

- { role: myrole, port: '7689' }

The template module didn't like the port variable then like this:

AnsibleUndefinedVariable: ERROR! 'port' is undefined

The port variable was undefined till I renamed it to something else...

@FractalizeR
Copy link

@meebey Yep. Very annoying, right? :)

@schnittchen
Copy link

I just bumped into this as well, exactly as @meeby did.

While I understand that the devs have more important things to do with currently more than 1k issues open, is there a list of reserved variables names somewhere, maybe a link to the code?

@bcoca
Copy link
Member

bcoca commented Apr 26, 2016

if only it where that simple, there are many and defined in different places

i added this for the basic objects, but far from a complete list http://docs.ansible.com/ansible/playbooks_directives.html

@schnittchen
Copy link

thanks @bcoca!

@ansibot ansibot added the affects_1.9 This issue/PR affects Ansible v1.9 label Sep 8, 2016
jimi-c pushed a commit that referenced this issue Dec 6, 2016
* Added support for dnos9_config module

* Addressed @gundalow comments
@bcoca bcoca added the affects_2.3 This issue/PR affects Ansible v2.3 label Jan 23, 2017
bcoca added a commit to bcoca/ansible that referenced this issue Jan 23, 2017
@bcoca bcoca mentioned this issue Jan 23, 2017
bcoca added a commit that referenced this issue Jan 31, 2017
* removed unused vars

* added warning when using reserved vars

fixes #4816

* cleanup
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_1.9 This issue/PR affects Ansible v1.9 affects_2.3 This issue/PR affects Ansible v2.3 c:vars/variable_manager feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants