ansible:促进对错误的警告

标签 ansible warnings

我有一些持续集成检查,运行了一些 ansible-playbook命令。每个剧本可能会运行许多剧本,包括许多大角色。

时不时地,有人会在 ansible-playbook 时引入一些导致警告的更改。运行,例如像这样:

[WARNING]: when statements should not include jinja2 templating delimiters
such as {{ }} or {% %}. Found: "{{ some_variable}}" not in
some_result.stdout

或者:
[WARNING]: Consider using unarchive module rather than running tar

或一些弃用警告,如:
[DEPRECATION WARNING]: ec2_facts is kept for backwards compatibility but usage 
is discouraged. The module documentation details page may explain more about 
this rationale.. This feature will be removed in a future release. Deprecation 
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

等等。有时,当我们升级 ansible 版本时会弹出这些警告。不管它们为什么会发生,我真的很想以某种方式拥有 ansible-playbook当命令导致这些警告之一时,命令会大声失败,而不是安静地继续并让我的 CI 检查成功。有没有办法做到这一点?我目前正在使用 ansible 2.4.3。

我发现很多关于 的方法的讨论隐藏 这些警告,但没有发现任何关于将它们提升为硬错误的信息。

最佳答案

我有完全一样的问题。我的解决方法是:

  • 使用 --check 和 'tee' 运行 playbook 到临时文件
  • 做一些 grep-magic 来过滤掉 'WARNING]:'
  • 做一些 grep-sed-magic 过滤掉不为零的结果(除了确定/跳过)

  • 我知道这并不理想,所以如果您提供了一个不错的解决方案,请分享:-)

    关于ansible:促进对错误的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50031257/

    相关文章:

    Ansible 剧本 : load internal inventory file while running

    C .pc 文件警告

    java - IntelliJ IDEA : How to display warnings in the project tree?

    Ansible dnf 模块启用 Fedora Copr 存储库

    variables - Ansible - 在运行时定义库存

    split - 具有多个定界符的 ansible string.split()

    Ansible - 仅在满足前提条件时运行一系列任务

    c++ - 警告 : uninitialized variable//But I have initialized ! C++ 编译器错误?

    clojure - 如何在 Clojure 中发出警告

    java - Jenkins/Buildr 运行 eclipse 编译器为 'javac',无需更改系统 java