0

我正在使用 ansible tower 并配置为运行 forks = 250。

我的任务很简单,它将从 4000 台主机等主机中提取的数据写入文件中。

例子:

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

这很好用,但最近我注意到缺少 400 个主机的行。这些主机没有任何问题,所以我唯一的线索是该模块lineinfile在文件中写入那么多行时有其局限性。

我想知道这里是否有人曾经或曾经遇到过这个问题以及任何替代方案。谢谢!

4

2 回答 2

0

不确定这是一个限制,lineinfile但将分叉从 250 减少到默认值可以解决问题。

于 2019-10-04T13:49:49.940 回答
0

我正在运行 Ansible 核心并注意到类似的问题。即使在少量主机(少于 10 个)上运行类似以下内容也会导致行丢失:

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

我可以解决这个问题的唯一方法是为该任务创建一个单独的游戏,serial: 1它看起来像:

- 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
于 2019-10-07T14:23:18.040 回答