mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add example of checking registered variable for emptiness. (#15510)
This commit is contained in:
parent
6a983b0fc4
commit
0eead1a3f6
1 changed files with 16 additions and 0 deletions
|
@ -271,6 +271,22 @@ fields::
|
||||||
with_items: home_dirs.stdout_lines
|
with_items: home_dirs.stdout_lines
|
||||||
# same as with_items: home_dirs.stdout.split()
|
# same as with_items: home_dirs.stdout.split()
|
||||||
|
|
||||||
|
As shown previously, the registered variable's string contents are accessible with the 'stdout' value.
|
||||||
|
You may check the registered variable's string contents for emptiness::
|
||||||
|
|
||||||
|
- name: check registered variable for emptiness
|
||||||
|
hosts: all
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: list contents of directory
|
||||||
|
command: ls mydir
|
||||||
|
register: contents
|
||||||
|
|
||||||
|
- name: check contents for emptiness
|
||||||
|
debug: msg="Directory is empty"
|
||||||
|
when: contents.stdout == ""
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue