1

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

hlovdal
  • 26,565
  • 10
  • 94
  • 165
sfgroups
  • 18,151
  • 28
  • 132
  • 204
  • 1
    The error doesn't sound like an Ansible error but like a yum error. Are you sure your command works on the target host? – peedee Jul 20 '19 at 11:17
  • my suggestion just for debugging would be to run the same command via `command` module in before using the `yum: enable` module – error404 Jul 20 '19 at 17:30
  • @peedee yes, I was able to run the command on that host. – sfgroups Jul 20 '19 at 19:40
  • @error404 now I am running command as shell command it works. – sfgroups Jul 20 '19 at 19:41
  • @sfgroups, have you tried using the [`yum_repository`](https://docs.ansible.com/ansible/latest/modules/yum_repository_module.html) module to add the repository, and then run the install task? – guzmonne Jul 24 '19 at 02:28

1 Answers1

1

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.

Eric Citaire
  • 4,355
  • 1
  • 29
  • 49