1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
Commit graph

10 commits

Author SHA1 Message Date
Pino Toscano
e0324cdc90
rhsm_repository: refactor parsing of "subscription-manager repos" output (#6837)
Simplify a bit (and possibly speed it up a little) the parsing of the
output of `subscription-manager repos --list`:
- simplify skipping the lines that are not interesting: check the first
  character only, as it is enough to determine whether it contains
  repository data or not
- check the start of each line manually, rather than with regexp: a
  simple slice + lstrip() gives the same result
2023-07-15 12:57:54 +02:00
Pino Toscano
867704dd75
rhsm_repository: refactor handling of subscription-manager (#6783)
Create a small helper class Rhsm, so all the logic related to the
interaction with subscription-manager is grouped there:
- create the Rhsm object in main(), once the initial checks are done
- search subscription-manager as required (so there is no need to
  manually check it), and store its path for reuse
- store the common arguments for running subscription-manager
- move run_subscription_manager() to Rhsm as run_repos()
- get rid of the different list parameters: we list only all the
  repositories, so the other cases are not needed (and can be added
  easily, if needed)
- move get_repository_list() to Rhsm as list_repositories()

The execution of subscription-manager is improved as well:
- pass the arguments to run_command() directly as list, rather than
  joining the arguments to string, which run_command() will need to
  split again
- move the "repos" parameter directly in run_repos()
- explicitly disable the shell, already off by default
- disable the expansions of variables, as there are none

Adapt the unit test to the different way run_command() is called.

There should be no behaviour changes.
2023-07-02 21:44:53 +02:00
Pino Toscano
ffb9b6ff96
rhsm_repository: update returned "repositories" when using "purge=true" (#6676)
In case the "purge" option was enabled, the "repositories" element in
the returned JSON was not updated with the repositories disabled by that
option.
2023-06-20 07:13:47 +02:00
Felix Fontein
eff0cb0ed9
Use semantic markup (modules r-s) (#6683)
* Use semantic markup.

* Use 'ignore:' for alias reference.

* Ignore sanity errors for older ansible-core versions.

* Improve markup for RHSM modules.

Co-authored-by: Pino Toscano <ptoscano@redhat.com>

* 'ignore:' is no longer needed.

* E() now works better.

---------

Co-authored-by: Pino Toscano <ptoscano@redhat.com>
2023-06-15 15:48:51 +02:00
Pino Toscano
2dbe529a90
rhsm_repository: deprecate "state=present" and "state=absent" (#6673)
"state=present" is broken, and acts like "disabled"; also, the
subscription repositories cannot be really "added" or "removed", which
is what "present" and "absent" would imply, but only enabled or
disabled. Hence, deprecate both these states, slating them for removal
in community.general 10.0.0.
2023-06-11 10:38:09 +02:00
Pino Toscano
9f67cbbe36
rhsm modules: cleanly fail when not run as root (#6211)
subscription-manager on RHEL installs a symlink in /usr/bin to
console-helper (part of usermode), which triggers an interactive prompt
for root credentials when run as user. It seems that console-helper
does not handle well non-interactive contexts (e.g. without a TTY for
input), and thus it will hang waiting for input when run as user in an
Ansible task.

Since subscription-manager requires root already anyway (and it will
fail when explicitly run as user), then apply the same logic locally on
all the modules that interact with it: redhat_subscription,
rhsm_release, and rhsm_repository.
2023-03-22 13:15:32 +01:00
Felix Fontein
d03ae532ed
Add attributes to more modules (3/4) (#5967)
Add attributes to more modules.
2023-02-20 17:30:26 +01:00
Felix Fontein
b531ecdc9b
Unflatmap community.general (#5461)
* Move files.

* Update imports and references.

* Move wrongly placed files.

* Reverse redirects, deprecate long → short name redirects.

* Simplify contribution guidelines for new modules.

* Rewrite BOTMETA.

* Add changelog fragment.

* Fix ignore.txt files.
2022-11-02 20:42:29 +00:00
Felix Fontein
7743ecd776
Replace symlinks with meta/runtime.yml redirects. (#4562) 2022-04-26 20:33:13 +02:00
Brian Coca
8f90360d49
make collection usable with current ansible vers (#9) 2020-03-11 14:10:38 +00:00