From 7e0a79530cc69c44bbe018c0ac80e0bb83bc6359 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 7 Jan 2023 16:44:27 +0100 Subject: [PATCH] alternatives: make work with Fedora 37 (#5794) * alternatives in Fedora 37 uses follower instead of slave. * Add changelog fragment. (cherry picked from commit 3b73e7ed2a550480892854ffb48314665a9b52c5) --- changelogs/fragments/5794-alternatives-fedora37.yml | 2 ++ plugins/modules/alternatives.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/5794-alternatives-fedora37.yml diff --git a/changelogs/fragments/5794-alternatives-fedora37.yml b/changelogs/fragments/5794-alternatives-fedora37.yml new file mode 100644 index 00000000000..bfb77142ccd --- /dev/null +++ b/changelogs/fragments/5794-alternatives-fedora37.yml @@ -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)." diff --git a/plugins/modules/alternatives.py b/plugins/modules/alternatives.py index 45661444938..48cacb45402 100644 --- a/plugins/modules/alternatives.py +++ b/plugins/modules/alternatives.py @@ -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'] @@ -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: