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

Ignore non-valid file extensions for include_vars dirs #35809

Merged
merged 1 commit into from May 31, 2018

Conversation

maxamillion
Copy link
Contributor

Signed-off-by: Adam Miller admiller@redhat.com

SUMMARY

Fixes #35745

Previously, if the dir contained any non-valid varfiles file extensions the module/task would error.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/action/include_vars.py

ANSIBLE VERSION
ansible 2.5.0 (include_vars 2dcfbd679a) last updated 2018/02/06 15:05:47 (GMT -500)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/admiller/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/admiller/src/dev/ansible/lib/ansible
  executable location = /home/admiller/src/dev/ansible/bin/ansible
  python version = 2.7.14 (default, Jan 17 2018, 14:28:32) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]

ADDITIONAL INFORMATION

Using the playbook:

---
- hosts: localhost
  tasks:
  - name: Fetch answer data
    git:
      repo: "https://github.com/maxamillion/ansible-bug-reproducers.git"
      version: master
      dest: /tmp/myvars/
      force: yes
  - include_vars:
      name: collected
      dir: "/tmp/myvars/35745-include_vars-file-extensions/vars"
      depth: 1
  - debug:
       var: collected

Before:

$(ansible)  ansible-playbook ~/src/abr/35745-include_vars-file-extensions/repro.yml
 [WARNING]: Could not match supplied host pattern, ignoring: all        
                                                                        
 [WARNING]: provided hosts list is empty, only localhost is available
                                                                        
                                                                                                                                                 
PLAY [localhost] ******************************************************************************************************************************  
                                                                                                                                                 
TASK [Gathering Facts] ************************************************************************************************************************
ok: [localhost]                                                         
                                                                                                                                                 
TASK [Fetch answer data] **********************************************************************************************************************
changed: [localhost]                                                                                                                             
                                                                        
TASK [include_vars] ***************************************************************************************************************************  
fatal: [localhost]: FAILED! => {"ansible_facts": {"collected": {}}, "ansible_included_var_files": [], "changed": false, "message": "/tmp/myvars/35745-include_vars-file-extensions/vars/README.md does not have a valid extension: yaml, yml, json"}
        to retry, use: --limit @/home/admiller/src/abr/35745-include_vars-file-extensions/repro.retry
                                                                        
PLAY RECAP ************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=1  

After:

$(ansible)  ansible-playbook ~/src/abr/35745-include_vars-file-extensions/repro.yml
 [WARNING]: Could not match supplied host pattern, ignoring: all         
                                                                                                                                                 
 [WARNING]: provided hosts list is empty, only localhost is available   
                                                                                                                                                 
                                                                        
PLAY [localhost] ******************************************************************************************************************************  
                                                                                                                                                 
TASK [Gathering Facts] ************************************************************************************************************************
ok: [localhost]                                                                                                                                  
                                                                                                                                                 
TASK [Fetch answer data] **********************************************************************************************************************
ok: [localhost]

TASK [include_vars] ***************************************************************************************************************************
ok: [localhost]

TASK [debug] **********************************************************************************************************************************
ok: [localhost] => {
    "collected": {
        "testing": "it works!"
    }
}

PLAY RECAP ************************************************************************************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=0


@ansibot ansibot added bugfix_pull_request 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 Feb 6, 2018
@samdoran
Copy link
Contributor

samdoran commented Feb 8, 2018

Further discussion is planned for the next meeting.

cc @bcoca

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Feb 8, 2018
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 16, 2018
@abadger
Copy link
Contributor

abadger commented Feb 20, 2018

We discussed at today's meeting but there was no maxamillion or bcoca. This seems like there's no downside (currently users with files in vars with unknown extensions will break. After this, the files will be ignored).

We'd like input from @bcoca or @maxamillion as to what the cons might be otherwise we're inclined to say go ahead and merge.

@abadger
Copy link
Contributor

abadger commented Feb 20, 2018

bcoca arrived during open floor and we talked this over. Decided that changing behaviour needs a toggle for backwards compat. We disagreed on whether the toggle could itself be part of a deprecation cycle to change the default behaviour (and potentially remove the failure as an option in the future). bcoca thinks that using a dir with filters should be done in jinja2 with a loop instead. I think that using these parameters as filters for which files to consider (which is what the documentation shows) is fine. The problem to me is that they're not filters, they're statements of files to error on.

Implementing a toggle is enough to move this forward.

@bcoca
Copy link
Member

bcoca commented Feb 20, 2018

fyi, jinja is not needed, that was one example, using the find module can get same results w/o having to deal with jinja

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 2, 2018
processing to ignore non-valid file extensions

Fixes ansible#35745

Signed-off-by: Adam Miller <admiller@redhat.com>
@maxamillion
Copy link
Contributor Author

sorry for the lag time on this, now with a new option to keep backwards compat

@ansibot
Copy link
Contributor

ansibot commented Mar 16, 2018

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Mar 16, 2018
@ansibot
Copy link
Contributor

ansibot commented Mar 16, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/utilities/logic/include_vars.py:0:0: E309 version_added for new option (ignore_unkown_extensions) should be 2.6. Currently 2.7

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Mar 16, 2018
@maxamillion
Copy link
Contributor Author

@abadger @nitzmahone ping - I was going to set the version of this to 2.7 and defer until then because 2.6 is a bugfix only and this is technically a feature but the sanity test is angry about that. Thoughts on how bets to handle this?

@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Mar 23, 2018
@mattclay
Copy link
Member

@maxamillion There's no way to avoid the error prior to merging until devel is for 2.7. Once stable-2.6 is branched this will pass CI, assuming no new issues come up.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 31, 2018
@maxamillion
Copy link
Contributor Author

rebuild_merge

@maxamillion
Copy link
Contributor Author

Oh bleh, nvm ... the branch hasn't happened yet. Tabling for now.

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 25, 2018
@ansibot ansibot added the core_review In order to be merged, this PR must follow the core review workflow. label May 31, 2018
@ansibot ansibot merged commit 39f7e05 into ansible:devel May 31, 2018
jacum pushed a commit to jacum/ansible that referenced this pull request Jun 26, 2018
processing to ignore non-valid file extensions

Fixes ansible#35745

Signed-off-by: Adam Miller <admiller@redhat.com>
@ansible ansible locked and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include_vars should not error on files with non-matching extensions
7 participants