Kai,

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.

Thanks again.

On Mon, May 4, 2020 at 5:18 PM Kai Stian Olstad <
[email protected]> wrote:

> On Mon, May 04, 2020 at 02:02:13PM -0700, Justin Nelson wrote:
> > The two hosts I have to test with are running 2.7.4 and 2.8.2. I don't
> have
> > a 2.9.x host available to test the throttle command but it makes sense.
> >
> > However, when I updated the playbook to the following:
> >
> > ---
> > - name: Test Playbook
> >   hosts:
> >     - test_group
> >   gather_facts: no
> >   connection: local
> >
> >   vars:
> >     user_home: "{{ lookup('env', 'HOME') }}"
> >     config_file: "{{ inventory_hostname }}.conf"
> >
> >   tasks:
> >     - name: Load device vars from config
> >       include_vars: "{{ user_home }}/{{ inventory_hostname }}.conf"
> >
> >     - 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'] }}"
> >
> > It ran as follows:
> >
> > PLAY [Test Playbook]
> >
> ************************************************************************************************************************************
> >
> > TASK [Load device vars from config]
> >
> *********************************************************************************************************************
> > ok: [host1]
> > ok: [host2]
> >
> > TASK [Update tmp file]
> >
> **********************************************************************************************************************************
> > changed: [host2] => (item=host1)
> > changed: [host1] => (item=host1)
> > changed: [host1] => (item=host2)
> > ok: [host2] => (item=host2)
>
> Here also you have two task writing to the same file at the same time.
> So here you need to add "run_once: yes" to the lineinfile task.
>
> --
> 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/20200504211803.rnrw6wb4rkawvmyo%40olstad.com
> .
>

-- 
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/CAH_brx3c%2B4EKnqbvfM651VZnQVyeHxw-RwQEuLV5xOcNj__EKg%40mail.gmail.com.

Reply via email to