On Thu, May 07, 2020 at 02:22:54PM -0400, Justin Nelson wrote:
> I just wanted to say thanks for your help in pointing out where I went
> wrong. Setting the play that was contending for a single file to serial: 1
> did the trick. When our ansible controller gets upgraded to 2.9 I'll use
> throttle to limit just that one task.
> 
> Everything is working as expected, and better than it was before.

You don't need run with serial: 1 if you use your loop below and add
run_once: yes.

That is what I do in cases like this because it's lot faster than serial: 1.


> > On Mon, May 04, 2020 at 02:02:13PM -0700, Justin Nelson wrote:
> > >     - name: Update tmp file
> > >       lineinfile:
> > >         path: "{{ playbook_dir }}/macs.yaml"
> > >         regexp: "^\ \ test[.-]{{ test_string|lower }}:.*"
> > >         line: "  test-{{test_string|lower}}: {{mac}}"
> > >         create: yes
> > >       loop: "{{ ansible_play_hosts }}"
> > >       vars:
> > >         test_string: "{{ hostvars[item]['test_string'] }}"
> > >         mac: "{{ hostvars[item]['mac'] }}"

  - name: Update tmp file
    lineinfile:
      path: "{{ playbook_dir }}/macs.yaml"
      regexp: "^\ \ test[.-]{{ test_string|lower }}:.*"
      line: "  test-{{test_string|lower}}: {{mac}}"
      create: yes
    loop: "{{ ansible_play_hosts }}"
    run_once: yes
    vars:
      test_string: "{{ hostvars[item]['test_string'] }}"
      mac: "{{ hostvars[item]['mac'] }}"

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200507184548.4mncbnlib3gktbfg%40olstad.com.

Reply via email to