feat(github_artifact): add force parameter to force installation

This commit is contained in:
NaeiKinDus 2024-07-07 00:00:00 +00:00
parent 890c7646fa
commit 5c67a916ee
Signed by: WoodSmellParticle
GPG key ID: 8E52ADFF7CA8AE56

View file

@ -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)