Skip to content

Commit

Permalink
To extend the wait_for states with timeout parameter
Browse files Browse the repository at this point in the history
To extend the wait_for states with timeout parameter.
The timeout value is taken from reclass pillar data if
defined. Oterwise, the states use the default value.

wait_for_deployed.sls
wait_for_ready.sls

Signed-off-by: ting wu <[email protected]>
  • Loading branch information
tiwuu committed Jun 4, 2018
1 parent e65e512 commit 22d0077
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,16 @@ Module function's example:
machines:
- kvm01
- kvm02
timeout: 1200 # in seconds
{%- if region.timeout is defined and region.timeout.ready is defined %}
timeout: {{ region.timeout.ready }}
{%- endif %}
req_status: "Ready"
- require:
- cmd: maas_login_admin
...
The timeout setting is taken from the reclass pillar data. If the pillar data is not defined, it will use the default value.
If module run w/\o any extra paremeters - `wait_for_machines_ready` will wait for defined in salt machines. In those case, will be usefull to skip some machines:
.. code-block:: bash
Expand All @@ -515,7 +519,9 @@ If module run w/\o any extra paremeters - `wait_for_machines_ready` will wait fo
module.run:
- name: maas.wait_for_machine_status
- kwargs:
timeout: 1200 # in seconds
{%- if region.timeout is defined and region.timeout.deployed is defined %}
timeout: {{ region.timeout.deployed }}
{%- endif %}
req_status: "Deployed"
ignore_machines:
- kvm01 # in case it's broken or whatever
Expand Down
3 changes: 3 additions & 0 deletions maas/machines/wait_for_deployed.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ wait_for_machines_deployed:
- name: maas.wait_for_machine_status
- kwargs:
req_status: "Deployed"
{%- if region.timeout is defined and region.timeout.deployed is defined %}
timeout: {{ region.timeout.deployed }}
{%- endif %}
- require:
- cmd: maas_login_admin
4 changes: 4 additions & 0 deletions maas/machines/wait_for_ready.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ maas_login_admin:
wait_for_machines_ready:
module.run:
- name: maas.wait_for_machine_status
- kwargs:
{%- if region.timeout is defined and region.timeout.ready is defined %}
timeout: {{ region.timeout.ready }}
{%- endif %}
- require:
- cmd: maas_login_admin
3 changes: 3 additions & 0 deletions tests/pillar/maas_region.sls
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ maas:
username: maas
enabled: true
salt_master_ip: 127.0.0.1
timeout:
deployed: 900
ready: 900

0 comments on commit 22d0077

Please sign in to comment.