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

Viewed 9317

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?

1 Answers

You can use the dpkg_selections module for this.

- name: Hold kubeadm
  dpkg_selections:
    name: kubeadm
    selection: hold

- name: Unhold kubeadm
  dpkg_selections:
    name: kubeadm
    selection: install
Related