Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

``apt-mark hold`` and ``apt-mark unhold`` with ansible modules

Tags:

ansible

apt

I'm writing my k8s upgrade ansible playbook, and within that I need to do apt-mark unhold kubeadm. Now, I am trying to avoid using the ansible command or shell module to call apt if possible, but the apt hold/unhold command does not seem to be supported by neither package nor apt modules.

Is it possible to do apt-mark hold in ansible without command or shell?

like image 505
Meitham Avatar asked Sep 20 '20 19:09

Meitham


People also ask

What is apt module in Ansible?

One of the most valuable features of Ansible is its ability to manage software packages on remote computers with the Ansible apt module. With an apt module, you can manage Ubuntu or Debian-based machines packages, such as updating the package to the latest version or installing multiple packages on a remote node.

How do I remove packages from Ansible?

If possible, you can destroy the machine using vagrant destroy and create/provision a new one. If it is not possible to destroy the machine and provision a new one then you can add an ansible task to remove the installed package. Using absent as the state will remove the package.


1 Answers

You can use the dpkg_selections module for this.

- name: Hold kubeadm
  dpkg_selections:
    name: kubeadm
    selection: hold
like image 199
Zeitounator Avatar answered Oct 11 '22 04:10

Zeitounator