【问题标题】:Ansible - get list of all of the changed files [after md5 check] [duplicate]Ansible - 获取所有已更改文件的列表 [在 md5 检查之后] [重复]
【发布时间】:2018-06-28 14:44:14
【问题描述】:

我的剧本包含这一步:

- name: copy remotely
  copy_remotely:
  src: "{{ tmp_dir }}/{{ item }}"
  dest: "{{ destination }}/{{item}}"
  with_list: "{{ find_results.stdout.split(\n) }}"
  register: checksum

此模块正在执行远程复制并检查 md5/checksum

寄存器“校验和”应该为我提供所有文件的列表 我需要获取已更改的项目。

当我运行这一步时:

- debug:
    msg: "{{item}}"
  with_items: "{{checksum.results}}"
  when: checksum is changed

我收到所有文件,即使它们没有更改,作为字典列表 我需要得到那些有“'改变':真实”状态的人。

可以吗???

【问题讨论】:

    标签: ansible ansible-2.x


    【解决方案1】:

    这样做:

      - name: Debug
        debug:
          msg: "{{item}}"
        with_items: "{{checksum.results}}"
        when: checksum.changed
    

    【讨论】:

    • 不工作,仍然接收所有文件,即使更改状态为假
    • 你能分享一下输出吗?我总是测试我的代码并且它可以工作
    • 输出类似于 [ { "name": "file1", "id" : "its id", changed: "false" }, { "name": "file2", "id" : "它的 id", 改变了: "true" }, { "name": "file3", "id" : "它的 id", 改变了: "false" } ]
    • 您的 file2 出于某种原因正在更改。你检查一下是否被复制?
    • 确定没问题。我想要的是仅获取已更改文件的输出,并且不接收有关未更改文件的信息
    猜你喜欢
    • 2019-07-01
    • 2014-07-29
    • 2019-04-16
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 2014-02-16
    • 1970-01-01
    • 2021-10-27
    相关资源
    最近更新 更多