Skip to content

Commit de58b4b

Browse files
committed
commands: Add support for retrying commands until a condition is reached
This can be useful for waiting for some state to change in the system.
1 parent 660ab59 commit de58b4b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

roles/commands/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ with at least one host in it - see the `cephadm` role for more details.
3333
- "fs new cephfs cephfs_metadata cephfs_data"
3434
- "orch apply mds cephfs --placement 3"
3535
```
36+
37+
* `cephadm_commands_until` A expression to evaluate to allow retrying commands. May reference the registered result variable, `cephadm_commands_result`. Default is `true` (do not use retries).
38+
39+
* `cephadm_commands_retries`: Number of retries to use with `cephadm_commands_until`. Default is 0.
40+
41+
* `cephadm_commands_delay`: Delay between retries with `cephadm_commands_until`. Default is 0.

roles/commands/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
---
22
cephadm_command: ceph
33
cephadm_commands: []
4+
cephadm_commands_until: true
5+
cephadm_commands_retries: 0
6+
cephadm_commands_delay: 0

roles/commands/tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
when: cephadm_commands | length > 0
1010
delegate_to: "{{ groups['mons'][0] }}"
1111
run_once: true
12+
until: cephadm_commands_until
13+
retries: "{{ cephadm_commands_retries }}"
14+
delay: "{{ cephadm_commands_delay }}"
1215
vars:
1316
# NOTE: Without this, the delegate hosts's ansible_host variable will not
1417
# be respected.

0 commit comments

Comments
 (0)