If it’s good to write a shell script in Ansible, you most likely have one thing like this:
- identify: iterate consumer teams
shell: groupmod -o -g {{ merchandise['guid'] }} {{ merchandise['username'] }}
with_items: "{{ customers }}"
However how do you write multiline shell scripts with this format?
Tips on how to write Multiline shell scripts
- identify: iterate consumer teams
shell: |
groupmod -o -g {{ merchandise['guid'] }} {{ merchandise['username'] }}
do_some_stuff_here
and_some_other_stuff
with_items: "{{ customers }}"
Simply observe that Ansible can do some unusual issues with manipulations of arguments, so you might need to comply with one thing like this:
- shell: |
cat <<EOF
This can be a check.
EOF
Or higher but, wrap them:
- shell:
cmd: |
cat <<EOF
This can be a check.
EOF