Search code examples
ansiblefedoralxddnfcopr

Ansible dnf module enable Fedora Copr repository


I want to enable a Fedora Copr repository with Ansible. More specifically I want to convert this command:

dnf copr enable ganto/lxd

Using an Ansible command module I overcome this problem but break the task's idempotence (if run again, the role should not make any changes) (changed_when: false is not an option).

- name: Enable Fedora Copr for LXD
  command: "dnf copr enable -y ganto/lxd"

Also, I tried this:

- name: Install LXD
  dnf:
    name: "{{ item }}"
    state: latest
    enablerepo: "xxx"
  with_items:
    - lxd
    - lxd-client

Where I test many variations for the option enablerepo without any success.

Is that possible using the dnf Ansible module (or something else)?


Solution

  • It is now possible thanks to https://docs.ansible.com/ansible/latest/collections/community/general/copr_module.html

    The original snippet using command

    - name: Enable Fedora Copr for LXD
      command: "dnf copr enable -y ganto/lxd"
    

    can be changed to

    - name: Enable Fedora Copr for LXD
      community.general.copr:
        name: ganto/lxd