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
allow 'ignore_missing' for fileglob lookups #47344
base: devel
Are you sure you want to change the base?
Conversation
Hi @philfry, thank you for submitting this pull-request! |
this is redundant with the 'errors' option available to all lookups. https://docs.ansible.com/ansible/latest/plugins/lookup.html#using-lookup-plugins |
The ---
- hosts: all
gather_facts: no
tasks:
- name: "with errors=strict"
debug: var=item
loop: '{{lookup("fileglob",
"files/"+inventory_hostname+"/iptables",
wantlist=true, errors="strict")}}'
- name: "with errors=ignore"
debug: var=item
loop: '{{lookup("fileglob",
"files/"+inventory_hostname+"/iptables",
wantlist=true, errors="ignore")}}'
- name: "with errors=warn"
debug: var=item
loop: '{{lookup("fileglob",
"files/"+inventory_hostname+"/iptables",
wantlist=true, errors="warn")}}'
...
|
ah, nvmd thought you wanted to handle an error, not a warning |
e0389d0
to
5d61144
Compare
5d61144
to
f57a138
Compare
affects_2.8, affects_2.9, affects_2.10, affects_2.11, … |
824a822
to
d295406
Compare
rebased (again) |
Please see also https://groups.google.com/g/ansible-project/c/C668U45mz7U why this option is maybe needed. |
Are you able to add an integration test for this, once in and passing I am happy to merge.
description: Flag to control whether or not no matches found return a warning | ||
type: boolean | ||
default: False | ||
version_added: "2.13" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay but 2.14 is now the latest devel version.
8280d2a
to
37c616d
Compare
I'm not sure. As far as I understood I cannot register the outputs (and thus warnings) from lookups. So something like this: - debug: msg="hello world"
loop: '{{q("fileglob", "/path/to/nowhere")}}'
register: foo or - set_fact: bar={{q("fileglob", "/path/to/nowhere")}}' won't result in having either |
true, register only takes in module/action output. You cannot get the warning but you can inspect the result in an assert/fail task:
|
Well I guess that test is already implemented |
SUMMARY
There are situations where it's useful to hide the
Unable to find ... in expected paths (use -vvvvv to see paths)
message. This PR adds the ability to passignore_missing
to thefileglob
plugin. See below for example.ISSUE TYPE
COMPONENT NAME
fileglob
ANSIBLE VERSION
ADDITIONAL INFORMATION
output: