On Friday, January 26, 2018 at 12:34:49 AM UTC-7, Kai Stian Olstad wrote:
>
> On 26.01.2018 00:53, John Harmon wrote: 
> > The more I read about this, the more I think it is working out of luck. 
> >  In 
> > fact, I don't understand how it is working now based on the output 
> > previously mentioned.  According to that both DNS1 and DNS2 should be 
> > pointing to dns2 or 10.1.1.11.  Thoughts? 
>
> Your nested has 3 levels and that gets you in trouble since you get this 
> four combinations 
> ifcfg-eth0 , ^DNS1.* , DNS1=10.1.1.10 
> ifcfg-eth0 , ^DNS1.* , DNS2=10.1.1.11 
> ifcfg-eth0 , ^DNS2.* , DNS1=10.1.1.10 
> ifcfg-eth0 , ^DNS2.* , DNS2=10.1.1.11 
>
> But you only want these two 
> ifcfg-eth0 , ^DNS1.* , DNS1=10.1.1.10 
> ifcfg-eth0 , ^DNS2.* , DNS2=10.1.1.11 
>
> So try this 
>
> - name: Add DNS entries to ifcfg-* files if missing 
>    lineinfile: 
>      path: "{{ net_path }}{{ item[0] }}" 
>      state: present 
>      regexp: "^{{ item[1] }}" 
>      line: "{{ item[1] }}={{ vars[item[1] | lower] }}" 
>    with_nested: 
>      - '{{ ifcfg_list.stdout_lines }}' 
>      - [ 'DNS1', 'DNS2' ] 
>
>
> -- 
> Kai Stian Olstad 
>   
>

Kai, thank you.  That is awesome.  I wouldn't have thought of that.  I do 
have some follow-up questions, just to understand. 

line: "{{ item[1] }}={{ vars[item[1] | lower] }}"
What does the = sign do here?  Is it overriding the with_nested item[1]?
What is vars specifying?  If I came close to ever doing this on my own I 
wouldn't have added vars.... so I am curious.
I know what the rest of it is doing, but am a little fuzzy in regards to 
the two things above.
 

-- 
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/67ed82a6-0e4a-48da-8309-5f7f2e0304c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to