How to pass options to dnf when using Ansible

Viewed 1245

When installing packages through the Ansible's dnf module. How do I pass options like --nobest to dnf? Is there alternative to using raw shell commands.

2 Answers

I had similar problem (but i'm using yum package manager) and figured a work around here

The issue is that docker-ce has not been packaged for CentOS 8 yet.

An ugly workaround is to install containerd.io manually beforehand:

pre_tasks:
  - yum:
     name: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

So, try to set full package url as package name and it should definitely work.

nobest can be passed as a parameter while using the DNF module in the playbook

You can refer here dnf_module for other options/parameters that can be passed to the dnf ansible module

For example :

- name: Install the latest version of Apache from the testing repo
  dnf:
    name: httpd
    enablerepo: testing
    state: present

- name: Install the latest version of Apache
  dnf:
    name: httpd
    state: present
    nobest: false
Related