在ansible中如何禁用单个任务的弃用警告?

k1e*_*ran 5 ansible ansible-2.x

我的任务之一在 ansible 2.8 中打印此警告

[DEPRECATION WARNING]: Use errors="ignore" instead of skip. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

有没有办法仅针对该一项任务禁用警告,因为我不想通过ansible.cfg.

顺便说一句,任务看起来像这样......

- name: Run platform specific tasks
  include_tasks: "{{ item }}"
  with_first_found:
    - files:
        - "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
        - "{{ ansible_distribution }}.yml"
        - "{{ ansible_os_family }}.yml"
      #
      # The following ansible 2.8 warning is misleading and fixed later
      #     See https://github.com/ansible/ansible/pull/60161
      #
      # [DEPRECATION WARNING]: Use errors="ignore" instead of skip. This feature will be removed in version 2.12.
      skip: true
Run Code Online (Sandbox Code Playgroud)

k1e*_*ran 3

我发现没有办法避免这个特定的弃用警告,所以只是记录了它存在的原因,记录中引用的是: https: //github.com/ansible/ansible/pull/60161

取消弃用跳过,因为错误的替代方法不适用于 with_first_found 并且只能使用查找

换句话说,这是 ansible 中的一个错误,已修复并合并到ansible:devel. 希望很快就会有包含此内容的版本,在那之前我将忍受这种噪音。

回答我自己的问题,以防这对其他人有帮助。