mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update an example.
This commit is contained in:
parent
10bc6f6d9c
commit
1867fb4888
1 changed files with 7 additions and 6 deletions
|
@ -800,10 +800,11 @@ The 'register' keyword decides what variable to save a result in. The resulting
|
||||||
- shell: echo "motd contains the word hi"
|
- shell: echo "motd contains the word hi"
|
||||||
when: motd_contents.stdout.find('hi') != -1
|
when: motd_contents.stdout.find('hi') != -1
|
||||||
|
|
||||||
As shown previously, the registered variable's string contents are accessible with the 'stdout' method.
|
As shown previously, the registered variable's string contents are accessible with the 'stdout' value.
|
||||||
The registered result can be used in the "with_items" of a task if it is converted into
|
The registered result can be used in the "with_items" of a task if it is converted into
|
||||||
a list (or already is a list) as shown below in another trivial example::
|
a list (or already is a list) as shown below. "stdout_lines" is already available on the object as
|
||||||
|
well though you could also call "home_dirs.stdout.split()" if you wanted, and could split by other
|
||||||
|
fields::
|
||||||
|
|
||||||
- name: registered variable usage as a with_items list
|
- name: registered variable usage as a with_items list
|
||||||
hosts: all
|
hosts: all
|
||||||
|
@ -815,9 +816,9 @@ a list (or already is a list) as shown below in another trivial example::
|
||||||
register: home_dirs
|
register: home_dirs
|
||||||
|
|
||||||
- name: add home dirs to the backup spooler
|
- name: add home dirs to the backup spooler
|
||||||
file: path=/mnt/bkspool/{{item}} src=/home/{{ item }} state=link
|
file: path=/mnt/bkspool/{{ item }} src=/home/{{ item }} state=link
|
||||||
with_items: home_dirs.stdout.split()
|
with_items: home_dirs.stdout_lines
|
||||||
|
# with_items: home_dirs.stdout.split()
|
||||||
|
|
||||||
Rolling Updates
|
Rolling Updates
|
||||||
```````````````
|
```````````````
|
||||||
|
|
Loading…
Reference in a new issue