微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在断言条件后将失败任务状态重定向到文件

如何解决在断言条件后将失败任务状态重定向到文件

我正在尝试查找文件系统 size_available 是否 > 1024MB 或不使用断言条件。我需要将成功/失败输出重定向到同一个文件,如果断言条件成功,下面是剧本,我能够在 CSV 文件获取成功,但我无法将失败状态写入文件,请建议如何将失败的断言条件写入 CSV 文件: -------------------------------------------------- ---------------- - 名称:检查 /boot 文件系统是否有 200M 可用空间 断言: 那: - item.size_available > {{ BOOT_LIMIT }} fail_msg: '/引导空间小于 {{ BOOT_LIMIT }}' success_msg: '/引导空间大于 {{ BOOT_LIMIT }}' 安静:真实 什么时候: item.mount == "/boot"enter code here with_items: "{{ ansible_mounts }}"

- name: Reporting Success nodes to csv in the next free column
  shell: "sed -i '/^{{ ansible_fqdn }}/ s/$/,{{ SUCCESS }}/g' {{ summary }}/patching_report.csv"
  delegate_to: localhost

----------------
Below is the output:
TASK [Check if /boot filesystem has 200M freespace] ********************************************************************************************************************
skipping: [localhost] => (item=None)
skipping: [localhost] => (item=None)
skipping: [localhost] => (item=None)
Failed: [localhost] (item=None) => changed=false
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
Failed: [172.17.254.201] (item=None) => changed=false
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
skipping: [localhost] => (item=None)
skipping: [172.17.254.201] => (item=None)
skipping: [localhost] => (item=None)
skipping: [172.17.254.201] => (item=None)
fatal: [172.17.254.201]: Failed! => changed=false
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
...ignoring
skipping: [localhost] => (item=None)
skipping: [localhost] => (item=None)
fatal: [localhost]: Failed! => changed=false
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
...ignoring

enter code here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。