From 5c67a916ee5b18f9b160ab5c68bd87a2ce2e5df1 Mon Sep 17 00:00:00 2001 From: NaeiKinDus Date: Sun, 7 Jul 2024 00:00:00 +0000 Subject: [PATCH] feat(github_artifact): add force parameter to force installation --- .../plugins/modules/github_artifact.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/collections/ansible_collections/nullified/infrastructure/plugins/modules/github_artifact.py b/collections/ansible_collections/nullified/infrastructure/plugins/modules/github_artifact.py index b94ced1..6379682 100644 --- a/collections/ansible_collections/nullified/infrastructure/plugins/modules/github_artifact.py +++ b/collections/ansible_collections/nullified/infrastructure/plugins/modules/github_artifact.py @@ -36,9 +36,14 @@ options: required: false default: [] creates: - description: if provided and target file / directory exists, this step will **not** be run + description: if provided and target file / directory exists, this step will **not** be run unless `--force` is specified type: str required: false + force: + description: forces the re-installation of the package no matter its state + type: bool + required: false + default: false github_token: description: a GitHub app token if you have one; limits impact of rate-limiting errors type: str @@ -291,6 +296,11 @@ def main(): "type": "str", "required": False }, + "force": { + "type": "bool", + "required": False, + "default": False + }, "repository": { "type": "str", "required": True @@ -323,7 +333,7 @@ def main(): DEFAULT_HEADERS["Authorization"] = "Bearer {}".format(ANSIBLE_MODULE.params["github_token"]) creates_file: str | None = ANSIBLE_MODULE.params.get("creates", None) - if creates_file and path.exists(creates_file): + if creates_file and path.exists(creates_file) and not ANSIBLE_MODULE.params.get("force", False): result["state"] = "ignored" ANSIBLE_MODULE.exit_json(**result)