gpt4 book ai didi

ansible - 如何忽略ansible中的警告

转载 作者:行者123 更新时间:2023-12-01 13:19:46 25 4
gpt4 key购买 nike

我在编写剧本时一直试图忽略警告,场景是我执行此 virt-host-validate qemu它会发出一个警告,如下所示。

root@n0:~/playbook_promenade# virt-host-validate 
QEMU: Checking for hardware virtualization : PASS
QEMU: Checking if device /dev/kvm exists :PASS
QEMU: Checking if device /dev/kvm is accessible : PASS
QEMU: Checking if device /dev/vhost-net exists : PASS
QEMU: Checking if device /dev/net/tun exists : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'memory' controller mount-point : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpu' controller mount-point: PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller mount-point : PASS
QEMU: Checking for cgroup 'devices' controller support : PASS
QEMU: Checking for cgroup 'devices' controller mount-point : PASS
QEMU: Checking for cgroup 'net_cls' controller support : PASS
QEMU: Checking for cgroup 'net_cls' controller mount-point : PASS
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for cgroup 'blkio' controller mount-point : PASS
QEMU: Checking for device assignment IOMMU support : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)`

我写的剧本如下。
`- hosts: localhost
sudo: yes
tasks:
- name: Check if Host supports Virtualization.
command: virt-host-validate qemu
ignore_errors: yes
failed_when: false
changed_when: false
register: host_status
- debug:
msg: "status: {{host_status.stdout}}"`

现在令人担忧的部分是,除了警告之外是否还有任何其他任务失败,因为我们正在使用 ignore_errors: yes任何人都可以请指导我如何解决它?
提前致谢。

最佳答案

我可以用这个解决它。

  tasks:
- name: Check if Host supports Virtualization.
command: virt-host-validate qemu
register: command_result
failed_when:
- "'FAIL' in command_result.stderr"

关于ansible - 如何忽略ansible中的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50677220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com