Skip to content

Commit

Permalink
[PR #5794/3b73e7ed backport][stable-6] alternatives: make work with F…
Browse files Browse the repository at this point in the history
…edora 37 (#5797)

alternatives: make work with Fedora 37 (#5794)

* alternatives in Fedora 37 uses follower instead of slave.

* Add changelog fragment.

(cherry picked from commit 3b73e7e)

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
patchback[bot] and felixfontein authored Jan 7, 2023
1 parent a1ca89b commit aa136ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/5794-alternatives-fedora37.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "alternatives - support subcommands on Fedora 37, which uses ``follower`` instead of ``slave`` (https://github.com/ansible-collections/community.general/pull/5794)."
8 changes: 5 additions & 3 deletions plugins/modules/alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
description:
- A list of subcommands.
- Each subcommand needs a name, a link and a path parameter.
- Subcommands are also named 'slaves' or 'followers', depending on the version
of alternatives.
type: list
elements: dict
aliases: ['slaves']
Expand Down Expand Up @@ -310,10 +312,10 @@ def parse(self):
current_mode_regex = re.compile(r'\s-\s(?:status\sis\s)?(\w*)(?:\smode|.)$', re.MULTILINE)
current_path_regex = re.compile(r'^\s*link currently points to (.*)$', re.MULTILINE)
current_link_regex = re.compile(r'^\s*link \w+ is (.*)$', re.MULTILINE)
subcmd_path_link_regex = re.compile(r'^\s*slave (\S+) is (.*)$', re.MULTILINE)
subcmd_path_link_regex = re.compile(r'^\s*(?:slave|follower) (\S+) is (.*)$', re.MULTILINE)

alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority\s(\d+)((?:\s+slave.*)*)', re.MULTILINE)
subcmd_regex = re.compile(r'^\s+slave (.*): (.*)$', re.MULTILINE)
alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority\s(\d+)((?:\s+(?:slave|follower).*)*)', re.MULTILINE)
subcmd_regex = re.compile(r'^\s+(?:slave|follower) (.*): (.*)$', re.MULTILINE)

match = current_mode_regex.search(display_output)
if not match:
Expand Down

0 comments on commit aa136ac

Please sign in to comment.