Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] COPR support #149

Closed
olifre opened this issue Nov 13, 2019 · 3 comments · Fixed by #215
Closed

[RFC] COPR support #149

olifre opened this issue Nov 13, 2019 · 3 comments · Fixed by #215

Comments

@olifre
Copy link

olifre commented Nov 13, 2019

This module does not have support for COPR yet, i.e. repos from https://copr.fedorainfracloud.org which are handled via yum-plugin-copr or dnf-plugins-core.

This is an RFC to find out if:

  • Devs think this should be in the scope of this module.
  • How to best implement it.

To trigger off discussion a bit, I am currently using a custom ressource defined like this:

define profile::repo::copr(
        String                                  $copr_repo      = $title,
        Enum['enabled', 'disabled', 'removed']  $ensure         = 'enabled',
) {
  $prereq_plugin = $facts['package_provider'] ? {
    'dnf'   => 'dnf-plugins-core',
    default => 'yum-plugin-copr',
  }
  ensure_packages([ $prereq_plugin ])
  if $facts['package_provider'] == 'dnf' {
    case $ensure {
      'enabled':
        {
          exec { "dnf -y copr enable ${copr_repo}":
            unless  => "dnf copr list | egrep -q '${copr_repo}\$'",
            require => Package[$prereq_plugin],
          }
        }
      'disabled':
        {
          exec { "dnf -y copr disable ${copr_repo}":
            unless  => "dnf copr list | egrep -q '${copr_repo} (disabled)\$'",
            require => Package[$prereq_plugin],
          }
        }
      'removed':
        {
          exec { "dnf -y copr remove ${copr_repo}":
            unless  => "dnf copr list | egrep -q '${copr_repo}'",
            require => Package[$prereq_plugin],
          }
        }
    }
  } else {
    $copr_repo_name_part = regsubst($copr_repo, '/', '-', 'G')
    case $ensure {
      'enabled':
        {
          exec { "yum -y copr enable ${copr_repo}":
            onlyif  => "test ! -e /etc/yum.repos.d/_copr_${copr_repo_name_part}.repo",
          }
        }
      'disabled', 'removed':
        {
          exec { "yum -y copr disable ${copr_repo}":
            onlyif  => "test -e /etc/yum.repos.d/_copr_${copr_repo_name_part}.repo",
          }
        }
    }
  }
}

which allows me to do:

profile::repo::copr { 'copart/restic':
  ensure  => 'enabled',
}
@dhoppe
Copy link
Member

dhoppe commented May 22, 2020

@traylenator I think this would be a great enhancement.

@NoodlesNZ
Copy link

Sounds fantastic. Can you create a PR?

@olifre
Copy link
Author

olifre commented Jun 10, 2021

Sounds fantastic. Can you create a PR?

Done, sorry it took me so long — I needed some time to learn how to write a working test 😉.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants