mvorisek
mvorisek

Reputation: 3428

Supress Ansible warning (at least for aptitude install)

How can I install aptitude package without ansible warning:

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

my install code looks like:

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

Upvotes: 3

Views: 3397

Answers (2)

ceving
ceving

Reputation: 23871

Or use module_defaults in your playbook, if you do not want to pollute your system with aptitude:

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

Upvotes: 6

mvorisek
mvorisek

Reputation: 3428

Fixed (specifically) for the aptitude install:

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

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

Upvotes: 9

Related Questions