Git Product home page Git Product logo

Comments (8)

ansibot avatar ansibot commented on September 28, 2024

Files identified in the description:

None

If these files are incorrect, please update the component name section of the description or use the component bot command.

from ansible.

flowerysong avatar flowerysong commented on September 28, 2024

This is not a bug. You are attempting to update a file multiple times simultaneously, so at least one update will make it into the file but some may not (depending on the exact timing of when each module execution reads and writes the file, which will vary between playbook runs.)

You should either template the entire file at once, or make sure you only run one lineinfile: task at a time (e.g. by using serial: or throttle:)

from ansible.

sivel avatar sivel commented on September 28, 2024

Closing per above.

If you have further questions please stop by IRC or the mailing list:

from ansible.

lurk-er avatar lurk-er commented on September 28, 2024

This is not a bug. You are attempting to update a file multiple times simultaneously, so at least one update will make it into the file but some may not (depending on the exact timing of when each module execution reads and writes the file, which will vary between playbook runs.)

You should either template the entire file at once, or make sure you only run one lineinfile: task at a time (e.g. by using serial: or throttle:)

Thats interesting, throttle made it consistent

from ansible.

bcoca avatar bcoca commented on September 28, 2024

You have to take into account that Ansible is parallel by default, but this does not lock files as the basic assumption is that the parallelism will affect different hosts. So if you want to do something like this you can use several solutions (some already explained above):

  • a callback (see the included tree callback)
  • a task with run: once and a template that writes the file in one shot
  • a play that runs on localhost
  • a task with throttle: 1, can keep lineinfile
  • a play with serial: 1, can keep lineinfile

from ansible.

lurk-er avatar lurk-er commented on September 28, 2024

You have to take into account that Ansible is parallel by default, but this does not lock files as the basic assumption is that the parallelism will affect different hosts. So if you want to do something like this you can use several solutions (some already explained above):
* a task with run: once and a template that writes the file in one shot
* a play that runs on localhost

These 2 did not work for me. The race condition still messed with the variables being written to the file.

from ansible.

bcoca avatar bcoca commented on September 28, 2024

There should be no race conditions as both only apply to a single host and hence only one fork.

from ansible.

lurk-er avatar lurk-er commented on September 28, 2024

When i tried it, it did not work. both template and/or localhost did not work

from ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.