That works! Thanks Kai.
On Thursday, March 22, 2018 at 8:39:55 AM UTC-6, Kai Stian Olstad wrote:
>
> On Wednesday, 21 March 2018 22.03.13 CET John Harmon wrote:
> > 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
>
> Have you tried using \n for the newline?
>
> --
> Kai Stian Olstad
>
--
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/061bd68c-8278-4241-92d9-60fc7f4595db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.