I have the following which works. However, I would like to make the bash 
script code "pretty".  It is found under the "content" section of the 
with_items.  How can I do this?

    - name: Ensure myscript.sh contains directory checks
      blockinfile:
        dest: "/home/{{ user.stdout }}/Scripts/myscript.sh"
        insertafter: "{{ item.regexp }}"
        marker: "## {mark} added by Ansible - {{ item.define }}"
        content: "{{ item.content }}"
      with_items:
        - { regexp: "^trap.*exit\ 1.*1\ 2\ 3\ .*", define: "Check for 
/interface", content: "if [ -f /interface/ ]; then echo 'The 
/interface/$NATU directory is missing, aborting!'; exit 1; fi" }
        - { regexp: "^NATU.*interface.*grep\ natu.*", define: "Check for 
/interface/natu", content: "if [ -f /interface/$NATU ]; then echo 'The 
/interface/$NATU directory is missing, aborting!'; exit 1; fi" }


I want to have the content injected into the file as follows (which can 
easily be done without a loop, but I wish to do this within the loop):
if [ -f /interface/ ]; then
  echo 'The /interface/$NATU directory is missing, aborting!'
  exit 1
fi

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5b42baa3-2134-4eff-b090-fab378126ab0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to