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

dnf: support config-manager plugin for repository management #46963

Closed
nullr0ute opened this issue Oct 12, 2018 · 32 comments
Closed

dnf: support config-manager plugin for repository management #46963

nullr0ute opened this issue Oct 12, 2018 · 32 comments
Labels
affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@nullr0ute
Copy link

nullr0ute commented Oct 12, 2018

SUMMARY

The dnf config-manager plugin is the means of managing the actual rpm repositories available to dnf. In Fedora it's use for managing installed but not enabled by default repositories such as updates-testing and some media codecs. In RHEL these repositories are used extensively for extras/optional and other such repos.

dnf config-manager supports the following options that would be useful to manage using ansible:

  • name - name to give to the rep, or the name of an existing repo
  • add-repo - URL of the repo
  • set-enabled - enable the repo specified by the name
  • set-disabled - disable the repo specified by the name
  • set-opt proxy - configure a proxy for the specified repo(s)

https://dnf-plugins-core.readthedocs.io/en/latest/config_manager.html

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

dnf module

ADDITIONAL INFORMATION

dnf provides a lot of repos and while the ansible dnf module enables you to manage installing/upgrading/removing packages and you can temporarily enable a repo as part of that process there is no means to manage the repositories themselves, so for example if you enable a repository to install a particular package but forget to enable that repository when applying updates you may miss critical updates to the packages that are installed by ansible. By managing being able to the repository you can enable the repository at the beginning of a task (eg fedora-cisco-openh264), install the package using the default means (ie not enabling the repo in the install component), and updates automatically get applied as part of an upgrade task without having to track what special usecases enabled repos as part of an install task.

@maxamillion maxamillion added the feature This issue/PR relates to a feature request. label Oct 12, 2018
@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

Hi @nullr0ute, thank you for submitting this issue!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

@nullr0ute: in order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • ansible version

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Oct 12, 2018
@maxamillion
Copy link
Contributor

@nullr0ute do you think should be an extension of the dnf module or be a net new module similar to the yum_repository module?

I'm leaning towards net new module but I'm open to discussion on the topic.

@ansibot
Copy link
Contributor

ansibot commented Dec 7, 2018

@thatnerdjosh
Copy link

thatnerdjosh commented Jan 9, 2019

@maxamillion if I may make a suggestion, a new module seems to make more sense here because when adding a repo one may not necessarily be installing a package... it seems it would be more work to integrate it into the dnf module than to make an entirely new one.

If it would be helpful, I could take this on to learn a bit about the ansible codebase

@maxamillion
Copy link
Contributor

@NerdsvilleCEO that would be amazing, I would greatly appreciate it! I'm happy to help along the way as well if you need anything. I'm always in #ansible on irc.freenode.net. My irc nick is the same as my github username. Thank you!

@pcfe
Copy link

pcfe commented Jan 19, 2019

Having this would be greatly appreciated.

I just ran into a case where I could not use the yum_repository module to set up repos for dnf; The setting for using deltaRPM differs between yum and dnf. So a module to properly manage dnf repositories would be very helpful (I'll temporarily help myself with other Ansible means).

I am happy to test once there is a dnf_repository module.

Things I can effortlessly test.

  • Define a new repo (I have a local updates mirror I use on my home boxes, I do not mirror deltaRPMs)
  • disable an existing repo
  • enable a repo

but I'm happy to test more if needed.

@ansibot ansibot added the packaging Packaging category label Feb 20, 2019
@MaartenMol
Copy link

Any development on this?

@ansibot
Copy link
Contributor

ansibot commented May 16, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added the needs_triage Needs a first human triage before being processed. label May 16, 2020
@thatnerdjosh
Copy link

There hasn't been, I'll take a look tomorrow, thank you for pinging @MaartenMol

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label May 18, 2020
@arioch
Copy link

arioch commented Jul 14, 2020

Gentle nudge...

@owenthereal
Copy link

Any update on this? I'm trying to automate the install of docker: https://docs.docker.com/engine/install/fedora/

@MaartenMol
Copy link

Any update on this? I'm trying to automate the install of docker: https://docs.docker.com/engine/install/fedora/

I had the same use case. Ended up wiht using Shell commands as workaround for the time being.

@maxamillion
Copy link
Contributor

Hey everyone, just checking in. This hasn't been forgotten but unfortunately it's not something I've had the cycles to get around to implementing. If anyone would like to submit a patch including the feature enhancement I would gladly review it. This is still on my TODO list, but unfortunately other things have been taking priority.

@sjpb
Copy link

sjpb commented Nov 6, 2020

Only 1 specific case but in case it helps anyone else, my current workaround for enabling a repo (powertools in this case, needed for centos8 only) was:

- name: Enable CentOS8 PowerTools repo
  # NB: doesn't run command  `dnf config-manager --set-enabled PowerTools` as can't make that idempotent
  lineinfile: 
    path: /etc/yum.repos.d/CentOS-PowerTools.repo
    create: false # so raise error if not already installed
    regexp: enabled=
    line: enabled=1
  when: ansible_distribution_major_version == "8"

@bnevis-i
Copy link

Perhaps an easier workaround?

command:
  cmd: dnf config-manager --add-repo (url)
  warn: false
args:
  creates: /etc/yum.repos.d/(something).repo

@thatnerdjosh
Copy link

I've been meaning to get to this for so long but haven't made much progress, if anyone is interested in this task feel free to take it

@MaartenMol
Copy link

We have moved on from CentOS to Ubuntu due to the latest developments.

@evenreven
Copy link

Perhaps an easier workaround?

command:
  cmd: dnf config-manager --add-repo (url)
  warn: false
args:
  creates: /etc/yum.repos.d/(something).repo

When it comes to set-enabled this won't work. CentOS 8 has several disabled repo files in this directory by default (that set-enabled enables), so checking for existence of the file itself won't do any good. Unless there's a module that uses an API to check for repos that are actually enabled, only lineinfile will work (unless I'm missing something).

@sjpb
Copy link

sjpb commented Apr 23, 2021

Yes you're right - the "add repo" and "enable repo" cases are different.

@evenreven
Copy link

I adapted your lineinfile task to a playbook of mine, btw. Thanks, @sjpb !

@WiSaGaN
Copy link

WiSaGaN commented May 14, 2021

Does https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_repository_module.html work for at least some of the command like "add/enable"?

@telometto
Copy link

Bumping this issue.

Imo, this is a pretty essential feature and should be added.

@strgalt-t
Copy link

Bump.

I'm currently using a shell command as a workaround but it would be a lovely addition to Ansible!

@ansibot ansibot added the has_pr This issue has an associated PR. label May 18, 2022
@telometto
Copy link

@maxamillion
I "made" an equivalent to the yum_repository module and tried to merge it, but the bot rejected it.

@bcoca
Copy link
Member

bcoca commented May 18, 2022

@telometto maximillion moved on to a diff position and is not part of the core team anymore.

The bot responds to all new modules/plugins by redirecting people to collections, since we split them out we are trying to keep those in core to a minimum.

But if you disagree and want to make your case for an exception, please feel free to add this to the core meeting irc agenda so the team can discuss and decide on this case. https://github.com/ansible/community/issues?q=is:open+label:meeting_agenda+label:core

@proxyconcept
Copy link

proxyconcept commented Aug 2, 2022

The repo configuration files are in "INI" format, so I think it's better to use the ini_file module.

What about this example ?

- name: "Enable AlmaLinux PowerTools repo"
  community.general.ini_file:
    path:       /etc/yum.repos.d/almalinux-powertools.repo
    section:    powertools
    option:     enabled
    value:      1
    create:     no
  when: ansible_distribution == "AlmaLinux"

It's clean, simple and really useful to specify the section name because some configuration file can define a lot of repos and you don't want to enable all.

@sjpb
Copy link

sjpb commented Aug 3, 2022

Good catch, thanks.

dgibbs64 added a commit to dgibbs64/ansible-role-linux_admin_packages that referenced this issue Aug 18, 2022
@DejfCold
Copy link

I too would appreciate existence of something like that. Would help me improve automation of ffmpeg in Rocky 9.

I could imagine something like:

- name: "Enable CRB repo"
  ansible.builtin.dnf_config_manager:
    name: crb
    enabled: yes

@sivel
Copy link
Member

sivel commented Nov 22, 2022

The dnf module should not be overloaded, and we are generally not adding or accepting new modules into core at this time.

Basically closing this per #46963 (comment)

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Nov 22, 2022
@sjpb
Copy link

sjpb commented Nov 23, 2022

I think "closed as completed" is a bit misleading! "Won't fix" would be clearer for the next person who finds this (and to be clear, I understand/accept the position that new modules are going into collections, not core).

@ansible ansible locked and limited conversation to collaborators Nov 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests