summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/general/plugins/modules/copr.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/community/general/plugins/modules/copr.py
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/general/plugins/modules/copr.py')
-rw-r--r--ansible_collections/community/general/plugins/modules/copr.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/ansible_collections/community/general/plugins/modules/copr.py b/ansible_collections/community/general/plugins/modules/copr.py
index 965c2a935..157a6c160 100644
--- a/ansible_collections/community/general/plugins/modules/copr.py
+++ b/ansible_collections/community/general/plugins/modules/copr.py
@@ -42,14 +42,14 @@ options:
type: str
state:
description:
- - Whether to set this project as C(enabled), C(disabled) or C(absent).
+ - Whether to set this project as V(enabled), V(disabled), or V(absent).
default: enabled
type: str
choices: [absent, enabled, disabled]
chroot:
description:
- The name of the chroot that you want to enable/disable/remove in the project,
- for example C(epel-7-x86_64). Default chroot is determined by the operating system,
+ for example V(epel-7-x86_64). Default chroot is determined by the operating system,
version of the operating system, and architecture on which the module is run.
type: str
"""
@@ -97,11 +97,26 @@ except ImportError:
DNF_IMP_ERR = traceback.format_exc()
HAS_DNF_PACKAGES = False
+from ansible.module_utils.common import respawn
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible.module_utils.basic import missing_required_lib
-from ansible.module_utils import distro # pylint: disable=import-error
-from ansible.module_utils.basic import AnsibleModule # pylint: disable=import-error
-from ansible.module_utils.urls import open_url # pylint: disable=import-error
+from ansible.module_utils import distro
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.urls import open_url
+
+
+def _respawn_dnf():
+ if respawn.has_respawned():
+ return
+ system_interpreters = (
+ "/usr/libexec/platform-python",
+ "/usr/bin/python3",
+ "/usr/bin/python2",
+ "/usr/bin/python",
+ )
+ interpreter = respawn.probe_interpreters_for_module(system_interpreters, "dnf")
+ if interpreter:
+ respawn.respawn_module(interpreter)
class CoprModule(object):
@@ -460,6 +475,7 @@ def run_module():
params = module.params
if not HAS_DNF_PACKAGES:
+ _respawn_dnf()
module.fail_json(msg=missing_required_lib("dnf"), exception=DNF_IMP_ERR)
CoprModule.ansible_module = module