summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorKate Case <kcase@redhat.com>2023-02-07 13:11:59 -0500
committerGitHub <noreply@github.com>2023-02-07 18:11:59 +0000
commitdac4b610c8a0dd67fad408649d855b8384017ddd (patch)
treef0ae8b94393a92227cf8210dc3146b9c30e4a541 /plugins
parenta4a40e9d4ec540fae1b4ecb1622786d0832ed840 (diff)
downloadvyos-ansible-collection-dac4b610c8a0dd67fad408649d855b8384017ddd.tar.gz
vyos-ansible-collection-dac4b610c8a0dd67fad408649d855b8384017ddd.zip
[command] run at least once when retries is 0 (#292)
* [command] run at least once when retries is 0 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/modules/vyos_command.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/modules/vyos_command.py b/plugins/modules/vyos_command.py
index 94f16f3..2ed920c 100644
--- a/plugins/modules/vyos_command.py
+++ b/plugins/modules/vyos_command.py
@@ -74,7 +74,8 @@ options:
- Specifies the number of retries a command should be tried before it is considered
failed. The command is run on the target device every retry and evaluated against
the I(wait_for) conditionals.
- default: 10
+ - The commands are run once when I(retries) is set to C(0).
+ default: 9
type: int
interval:
description:
@@ -175,7 +176,7 @@ def main():
commands=dict(type="list", required=True, elements="raw"),
wait_for=dict(type="list", aliases=["waitfor"], elements="str"),
match=dict(default="all", choices=["all", "any"]),
- retries=dict(default=10, type="int"),
+ retries=dict(default=9, type="int"),
interval=dict(default=1, type="int"),
)
@@ -186,6 +187,7 @@ def main():
commands = parse_commands(module, warnings)
wait_for = module.params["wait_for"] or list()
+ conditionals = []
try:
conditionals = [Conditional(c) for c in wait_for]
except AttributeError as exc:
@@ -195,7 +197,8 @@ def main():
interval = module.params["interval"]
match = module.params["match"]
- for item in range(retries):
+ # Always run at least once, and then `retries` more times.
+ for item in range(retries + 1):
responses = run_commands(module, commands)
for item in list(conditionals):