On Saturday, March 22, 2014 3:54:47 PM UTC-7, John Murphy wrote:
>
> I feel like I'm missing something obvious here:
>
> Example of lineinfile with different insertbefore
 

>
> What am I doing wrong?
>

Nothing..  But Ansible is doing what you tell it, probably not what you 
want.. The documentation is pretty clear, but perhaps not emphatic enough.

If you look at the expansion of what you are running you are basically 
running this...

-    lineinfile: dest=/etc/yum.repos.d/CentOS-Base.repo 
insertbefore='^#additional packages that may be useful' 
line='exclude=postgresql*' state=present
-    lineinfile: dest=/etc/yum.repos.d/CentOS-Base.repo 
insertbefore='^#released updates' line='exclude=postgresql*' state=present

So the first item looks at the file, finds that exclude=postgresql* doesn't 
exist and so adds it before #additional packages that may be useful.  Then 
it gets to the next line and it finds the line in the file so it doesn't 
change it.

To get two entries in the file you will have to edit your task.  You may be 
able to change your insertbefore to regexp and then change your line to 
something like line='exclude=postgresql*\n{{ item }}'  I haven't tried this 
but it MIGHT work.

I hope that this helps, 

Adam

-- 
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/52953ae5-9162-4488-b923-a8de6993d7d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to