shell 抑制Ansible警告(至少对于aptitude安装)

h5qlskok  于 2023-04-21  发布在  Shell
关注(0)|答案(2)|浏览(82)

如何在没有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
xxhby3vn

xxhby3vn1#

已修复(特别针对aptitude安装):

- 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

ippsafx7

ippsafx72#

或者在playbook中使用module_defaults,如果您不想让aptitude污染您的系统:

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

相关问题