1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update documentation for ignore_unknown_extensions (#50383)

* Example updated
* Testcase added

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2019-01-22 23:26:10 +05:30 committed by Brian Coca
parent b005854672
commit 7561aaf619
3 changed files with 38 additions and 1 deletions

View file

@ -122,6 +122,12 @@ EXAMPLES = """
dir: vars
ignore_files: [bastion.yaml]
extensions: [yaml]
- name: Ignore warnings raised for files with unknown extensions while loading (2.7)
include_vars:
dir: vars
ignore_unknown_extensions: True
extensions: ['', 'yaml', 'yml', 'json']
"""
RETURN = '''

View file

@ -40,9 +40,23 @@
- "testing == 123"
- "base_dir == 'all'"
- name: include var files with extension only
include_vars:
dir: webapp
ignore_unknown_extensions: True
extensions: ['', 'yaml', 'yml', 'json']
register: include_without_file_extension
- name: verify that only files with valid extensions are loaded
assert:
that:
- webapp_version is defined
- "'file_without_extension' in '{{ include_without_file_extension.ansible_included_var_files | join(' ') }}'"
- name: include every directory in vars
include_vars:
dir: vars
extensions: ['', 'yaml', 'yml', 'json']
register: include_every_dir
- name: verify that the correct files have been loaded and overwrite based on alphabetical order
@ -51,17 +65,19 @@
- "testing == 456"
- "base_dir == 'services'"
- "webapp_containers == 10"
- "{{ include_every_dir.ansible_included_var_files | length }} == 4"
- "{{ include_every_dir.ansible_included_var_files | length }} == 5"
- "'vars/all/all.yml' in include_every_dir.ansible_included_var_files[0]"
- "'vars/environments/development/all.yml' in include_every_dir.ansible_included_var_files[1]"
- "'vars/environments/development/services/webapp.yml' in include_every_dir.ansible_included_var_files[2]"
- "'vars/services/webapp.yml' in include_every_dir.ansible_included_var_files[3]"
- "'vars/webapp/file_without_extension' in include_every_dir.ansible_included_var_files[4]"
- name: include every directory in vars except files matching webapp.yml
include_vars:
dir: vars
ignore_files:
- webapp.yml
- file_without_extension
register: include_without_webapp
- name: verify that the webapp.yml file was not included
@ -71,6 +87,7 @@
- "base_dir == 'environments/development'"
- "{{ include_without_webapp.ansible_included_var_files | length }} == 2"
- "'webapp.yml' not in '{{ include_without_webapp.ansible_included_var_files | join(' ') }}'"
- "'file_without_extension' not in '{{ include_without_webapp.ansible_included_var_files | join(' ') }}'"
- name: include only files matching webapp.yml
include_vars:
@ -100,3 +117,15 @@
- "webapp['testing'] == 101112"
- "webapp['base_dir'] == 'development/services'"
- "webapp['webapp_containers'] == 20"
- name: include var files without extension
include_vars:
dir: webapp
ignore_unknown_extensions: False
register: include_with_unknown_file_extension
ignore_errors: True
- name: verify that files without valid extensions are loaded
assert:
that:
- "'a valid extension' in include_with_unknown_file_extension.message"

View file

@ -0,0 +1,2 @@
---
webapp_version: "1"