Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Enable/disable/list repos using redhat_subscription module #3300

Closed
ghost opened this issue Mar 22, 2016 · 16 comments
Closed

Enable/disable/list repos using redhat_subscription module #3300

ghost opened this issue Mar 22, 2016 · 16 comments

Comments

@ghost
Copy link

ghost commented Mar 22, 2016

Issue Type:
  • Feature Idea
Plugin Name:

redhat_subscription

Ansible Version:

N/A

Ansible Configuration:

N/A

Environment:

N/A

Summary:

redhat_subscription module does not contains options to enable/disable/list repos.
When connecting a server to the rhn or satellite and assign a subscription without activation keys, its necessary to enable or disable repos.

Steps To Reproduce:

subscription-manager command provides those options:

  • Enable: subscription-manager repos --enable repo [--enable repo] [--enable regexp]
  • Disable: subscription-manager repos --disable repo [--disable repo] [--disable regexpr]
  • List all: subscription-manager repos --list
  • List enabled: subscription-manager repos --list-enabled
  • List disabled: subscription-manager repos --list-disabled
@jfenal-zz
Copy link

As for needs:

  • get list of repos currently enabled on the machine
  • enable if not yet enabled a repos or a list of repos (in one command, as subscription-manager is slooooow)
  • same for disabling a list of repos, with special '*' to disable all repos (and build on a clean state)

@samdoran
Copy link
Contributor

I would like this functionality as well. I'm wondering about the best way to go about implementing it.

Would it make sense to add this to the existing redhat_subscription module given the state: parameter would then be ambiguous, i.e., is the repo enabled ( repos --enable vs repos --disable) or is the subscription enabled (register vs. unregister)? Adding a repo_state parameter would remove the amibiguity, but seems a little gross.

Or would it be better to split this out into a separate redhat_repository module so it's clear exactly what is being enabled/disabled (singular name to make @abadger happy)?

@minusdavid
Copy link

Since the modules "rhn_channel" and "rhn_register" already exist, I think it would be reasonable and consistent to create a new module called "redhat_repository" to go alongside "redhat_subscription".

By the way, I'd also like this functionality. I wonder how people are managing their repos using subscription-manager in Ansible at the moment. Using the command/shell modules I'm guessing?

@minusdavid
Copy link

As a short-term measure, I'm writing a custom "site_facts" module which will parse redhat.repo, and then I can use that with some conditionals to do "command: subscription-manager repos...".

It's not really that different from the concept behind http://docs.ansible.com/ansible/include_vars_module.html I imagine... except instead of YAML/JSON it's the INI type format that Python uses with ConfigParser.

I'm going to look at it again on Monday, and if I can make it nice and clean, I'll post it on my own Github account for anyone else who wants to use it.

@jfenal-zz
Copy link

I've started writing such a module, but was interrupted before I could finish a first version I could test.
Have a look at : https://github.com/jfenal/ansible-modules-jfenal
The logic is mostly there, BUT not tested at all, no JSON output, no error handling. It clearly lacks some more code to be functional, but close.

Please note my disclaimer : my first ansible module, and moreover, my first attempt to write (with lots of copy/pasting) python code. Cave canem :)

@samdoran
Copy link
Contributor

I have a role that's using command to manage subscriptions and repos.

@minusdavid
Copy link

Kudos for your work, guys!

@samdoran I take it that's not idempotent, so you use tags to just run it once during initial setup?

@jfenal Looks ambitious! I opted for a local custom module, which you can see at this Gist

@minusdavid
Copy link

Btw, it works well enough. I like the idea of a core redhat_repository module best, but this will certainly do the job for now.

@minusdavid
Copy link

Just realized that you both appear to work at Red Hat.

I'm super curious about if/how RH is developing Ansible to help manage RHEL...

I've only been using RHEL for a couple of weeks, but I've used Ansible for a couple years. So far so good using it to setup RHEL servers. The only real sticking point so far has been this issue. Well, and this one, but perhaps this comment section isn't the best place for discussing such things.

@detiber
Copy link
Contributor

detiber commented Sep 8, 2016

@barnabycourt not sure if you've seen this bug

@ansibot
Copy link

ansibot commented Oct 6, 2016

@barnabycourt, @alikins, ping. This issue is still waiting on your response.
click here for bot help

@jfenal-zz
Copy link

@ansibot
Copy link

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@jfenal-zz
Copy link

jfenal-zz commented Dec 27, 2016

For followers of this thread, please have a look at https://github.com/jfenal/ansible-modules-jfenal, all feedbacks are welcome before I submit it to ansible core.

@detiber
Copy link
Contributor

detiber commented Jan 3, 2017

@barnabycourt might be of interest to you.

@rvalente
Copy link

This issue was moved to ansible/ansible#28159

@ansibot ansibot closed this as completed Aug 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants