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

Create with_items example with a registered var #3541

Merged
merged 1 commit into from
Jul 19, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions docsite/latest/rst/playbooks2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,24 @@ The 'register' keyword decides what variable to save a result in. The resulting
- action: shell echo "motd contains the word hi"
when: motd_contents.stdout.find('hi') != -1

As shown previously, the registered variable's string contents are accessible with the 'stdout' method.
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::


- name: registered variable usage as a with_items list
hosts: all

tasks:

- name: retrieve the list of home directories
command: ls /home
register: home_dirs

- name: add home dirs to the backup spooler
file: path=/mnt/bkspool/{{item}} src=/home/{{ item }} state=link
with_items: home_dirs.stdout.split()


Rolling Updates
```````````````
Expand Down