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

playbook_vars_root doesn't work for playbook imports #34239

Closed
kustodian opened this issue Dec 26, 2017 · 4 comments
Closed

playbook_vars_root doesn't work for playbook imports #34239

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

Comments

@kustodian
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Core/Variable manager

ANSIBLE VERSION
ansible 2.4.3.0 (stable-2.4 8708105616) last updated 2017/12/26 11:11:12 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/testuser/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/testuser/git/ansible/lib/ansible
  executable location = /home/testuser/git/ansible/bin/ansible
  python version = 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]

But it also doesn't work on 2.4.2 and current devel.

CONFIGURATION

N/A

OS / ENVIRONMENT

Ubuntu 17.10

SUMMARY

playbook_vars_root configuration doesn't work at all. It always work as if it is set to bottom, which was the default in 2.4.0 by mistake. In 2.4.1 the default should've been fixed to be top again, as it was in <=2.3, but it's not. It's still bottom and configuring playbook_vars_root = top, doesn't make a difference, the setting is just ignored. I also tried using the environment variable ANSIBLE_PLAYBOOK_VARS_ROOT=top, but still the same problem.

STEPS TO REPRODUCE

Create the following file structure:

$ tree --dirsfirst -r
.
├── top
│   ├── group_vars
│   │   └── all.yml
│   └── top.yml
├── middle
│   ├── group_vars
│   │   └── all.yml
│   └── middle.yml
├── bottom
│   ├── group_vars
│   │   └── all.yml
│   └── bottom.yml
└── invetory.ini

With the following content:

# top/group_vars/all.yml
---
top: yes
precedence: top
# top/top.yml
---
- include: ../middle/middle.yml
# middle/group_vars/all.yml
---
middle: yes
precedence: middle
# middle/middle.yml
---
- include: ../bottom/bottom.yml
# bottom/group_vars/all.yml
---
bottom: yes
precedence: bottom
# bottom/bottom.yml
---
- hosts: localhost
  tasks:
    - debug:
        var: top
    - debug:
        var: middle
    - debug:
        var: bottom
    - debug:
        var: precedence
# inventory.ini
localhost ansible_connection=local
EXPECTED RESULTS

If we run the top/top.yml playbook on 2.3 we would get the expected results where only the top var will be set and precedence=top:

$ ansible-playbook -i invetory.ini top/top.yml

PLAY [localhost] ***************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "top": true
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "middle": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "bottom": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "precedence": "top"
}
ACTUAL RESULTS

But, if we run this on Ansible 2.4/2.5 (this is 2.4.3 from stable-2.4 branch):

$ ansible-playbook -i invetory.ini top/top.yml
[DEPRECATION WARNING]: 'include' for playbook includes. You should use 'import_playbook' instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [localhost] ***************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "top": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "middle": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "bottom": true
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "precedence": "bottom"
}

The same thing happens if we set ANSIBLE_PLAYBOOK_VARS_ROOT=top or to any value:

$ ANSIBLE_PLAYBOOK_VARS_ROOT=top ansible-playbook -i invetory.ini top/top.yml
[DEPRECATION WARNING]: 'include' for playbook includes. You should use 'import_playbook' instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [localhost] ***************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "top": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "middle": "VARIABLE IS NOT DEFINED!"
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "bottom": true
}

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "precedence": "bottom"
}

The outcome is exactly the same in we configure playbook_vars_root = top in ansible.cfg.
The conclusion is that playbook_vars_root/ANSIBLE_PLAYBOOK_VARS_ROOT is currently broken.

@ansibot
Copy link
Contributor

ansibot commented Dec 26, 2017

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 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 26, 2017
@kustodian
Copy link
Contributor Author

!component =lib/ansible/vars/manager.py

@ansibot
Copy link
Contributor

ansibot commented Dec 26, 2017

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@maxamillion maxamillion removed the needs_triage Needs a first human triage before being processed. label Jan 2, 2018
@kustodian kustodian changed the title playbook_vars_root doesn't work [Regression] playbook_vars_root doesn't work Jan 5, 2018
@bcoca bcoca changed the title [Regression] playbook_vars_root doesn't work playbook_vars_root doesn't work Feb 14, 2018
@bcoca bcoca changed the title playbook_vars_root doesn't work playbook_vars_root doesn't work for playbook imports Feb 14, 2018
@bcoca
Copy link
Member

bcoca commented Feb 14, 2018

dupe of #33177

@bcoca bcoca closed this as completed Feb 14, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 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

4 participants