Supress Ansible警告(至少对于智能安装)

时间:2019-06-25 23:10:16

标签: shell ansible

如何在没有警告的情况下安装aptitude软件包:

TASK [... : APT: Install aptitude package] ********************************************************************************
 [WARNING]: Could not find aptitude. Using apt-get instead

我的安装代码如下:

- name: "APT: Install aptitude package"
  apt:
    name: aptitude
#  vars:
#    ACTION_WARNINGS: false << DOES NOT WORK

2 个答案:

答案 0 :(得分:3)

或者,如果您不想以智能来污染您的系统,请在您的playbook中使用module_defaults

---
- hosts: ...
  module_defaults:
    apt:
      force_apt_get: yes
  tasks:
    - ...

答案 1 :(得分:2)

(特别是)针对智能安装进行了修复:

- name: "APT: Install aptitude package"
  apt:
    name: aptitude
    force_apt_get: yes

基于https://github.com/ansible/ansible/blob/stable-2.8/lib/ansible/modules/packaging/os/apt.py#L1059