Create Ansible task for yum command

258 Views Asked by At

I am trying to convert this yum command to Ansible task:

yum -y install yum-plugin-copr
yum -y copr enable @spacewalkproject/nightly-client

created task like this, but giving error.

  - name:  Install repository yum-plugin-copr
    yum:
      name: "{{ packages }}"
    vars:
      packages:
      - yum-plugin-copr

  - name: Install repository Spacewalk-Client 
    yum:
      name: copr
      enablerepo: "@spacewalkproject/nightly-client"
      state: present

Error:

Error setting/accessing repos: Error getting repository data for @spacewalkproject/nightly-client, repository not found

What is the right way to convert this command to Ansible task?

Thanks SR

1

There are 1 best solutions below

0
Eric Citaire On

The yum module is meant to install, remove, update and list Yum packages. It doesn't support sub-commands from plugins like YUM Copr Plugin. Therefore, you can't expect to call yum copr sub-command by using this module.

There is an opened issue to add support to Copr in dnf module, you should take a look and subscribe to the discussion.

Meanwhile, you could try to add the repository with yum_repository module, or simply call yum copr with the shell module.