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

Fixes # if include_vars dir is file instead of directory code breaks #31157

Merged
merged 1 commit into from
Oct 3, 2017
Merged

Fixes # if include_vars dir is file instead of directory code breaks #31157

merged 1 commit into from
Oct 3, 2017

Conversation

shuklaabhi
Copy link
Contributor

@shuklaabhi shuklaabhi commented Oct 1, 2017

SUMMARY

Bug fix for include_var plugin

  • name: 'Include all variables'
    include_vars:
    dir: 'vars/webserver'
    extensions: ['yml']

Include_var plugin expects a directory in dir parameter. However if its a file instead of directory the code breaks.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

include_vars plugin

ANSIBLE VERSION
ansible 2.4.0.0
  config file = None
  configured module search path = ['/home/xtreme/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xtreme/helper-venv/lib/python3.6/site-packages/ansible
  executable location = /home/xtreme/helper-venv/bin/ansible
  python version = 3.6.2 (default, Aug 12 2017, 21:28:03) [GCC 5.4.0 20160609]

ADDITIONAL INFORMATION

If the dir param is a file instead of a directory for the include_vars plugin the code breaks with following error.

Before:
  File "/home/xtreme/helper-venv/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 125, in run
    res = self._execute()
  File "/home/xtreme/helper-venv/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 528, in _execute
    result = self._handler.run(task_vars=variables)
  File "/home/xtreme/helper-venv/lib/python3.6/site-packages/ansible/plugins/action/include_vars.py", line 142, in run
    if failed:
UnboundLocalError: local variable 'failed' referenced before assignment

After change it gives you a message that given path is not a directory.

TASK [webserver : Include all variables] *************************************************************************************************************************
task path: /home/xtreme/workspace/gearbox/gearbox.git/ops/deploy/roles/webserver/tasks/main.yml:2
fatal: [54.210.139.47]: FAILED! => {
"ansible_facts": {},
"ansible_included_var_files": [],
"changed": false,
"failed": true,
"message": "vars/webserver is not a directory"
}

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request needs_triage Needs a first human triage before being processed. plugins/action python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 1, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Oct 2, 2017
@bcoca bcoca added this to Nominated in 2.4.x Blocker List Oct 2, 2017
@bcoca
Copy link
Member

bcoca commented Oct 2, 2017

rebuild_merge

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Oct 3, 2017
@ansibot ansibot merged commit d0c003a into ansible:devel Oct 3, 2017
abadger pushed a commit that referenced this pull request Oct 3, 2017
@abadger abadger moved this from Nominated to Done in 2.4.x Blocker List Oct 3, 2017
@abadger
Copy link
Contributor

abadger commented Oct 3, 2017

cherrypicked for 2.4.1beta2

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. plugins/action python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
No open projects
2.4.x Blocker List
Done in 2.4.1
Development

Successfully merging this pull request may close these issues.

None yet

4 participants