1

I'm using ansible tower and configured to run forks = 250.

My tasks is simple, it writes in a file data extracted from hosts like 4000 hosts.

example:

      - name: creating report
        lineinfile: dest="reports/{{ report_name }}.csv" line="{{ inventory_hostname }},{{ item }}" 
        insertafter=EOF create=yes
        with_items: "{{ report_result.stdout_lines | trim }}"

That works well, but recently i have noticed lines missing like 400 hosts. There is nothing wrong with those hosts, so the only lead i have is that the module lineinfile has its limitations while writing that many lines in a file.

I'm wondering if anybody here have or had this problem before and any alternatives. thanks!

eduprado
  • 81
  • 1
  • 4

3 Answers3

0

Not sure this is a limitation on lineinfile but reducing the forks from 250 to default fixed the problem.

eduprado
  • 81
  • 1
  • 4
0

I am running Ansible core and have noticed a similar issue. Running something like the following even on a small # of hosts (less than 10) causes lines to be missing:

  - name: "Generate Summary Report Line"
    lineinfile:
      path: "{{ report_sum_file }}"
      line: "some text that is different per {{host}}"
    delegate_to: localhost

The only way I could work around this was to create a separate play for that task with serial: 1 which looks like:

- name: Write Report Lines
  hosts: all
  gather_facts: no
  serial: 1

  tasks:
    - name: "Generate Summary Report Line"
      lineinfile:
        path: "{{ report_sum_file }}"
        line: "some text that is different per {{host}}"
      delegate_to: localhost
-1

Adding serial: 1 is the only thing worked for me as well

  • This looks more like a comment rather than a new answer. – Eric Aya May 09 '22 at 19:20
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '22 at 12:22