Resource Type: wait_for
- Defined in:
- lib/puppet/type/wait_for.rb
- Providers:
-
wait_for
Overview
Wait for something to happen.
This was based on an original idea by Bastian Krol and then later rewritten, using the built-in Exec type as a starting point, in order to implement Exec’s refreshonly functionality.
A lot of this code is copy/pasted from Exec.
Properties
-
exit_code
The expected exit code(s). An error will be returned if the executed command has some other exit code. Defaults to 0. Can be specified as an array of acceptable exit codes or a single value.
This property is based on the Exec returns property.
-
refreshonly
Based on the Exec refreshonly parameter.
The command should only be run as a refresh mechanism for when a dependent object is changed. It only makes sense to use this option when this command depends on some other object; it is useful for triggering an action:
service { 'logstash': ensure => running, enable => true, } # Wait for the service to really start. wait_for { 'logstash': query => 'cat /var/log/logstash/logstash-plain.log 2> /dev/null', regex => 'Successfully started Logstash API endpoint', polling_frequency => 5, # Wait up to 2 minutes. max_retries => 24, refreshonly => true, }
Note that only ‘subscribe` and `notify` can trigger actions, not `require`, so it only makes sense to use `refreshonly` with `subscribe` or `notify`.
Supported values:- true
- false
-
regex
A regex pattern that is used in conjunction with the query parameter. The query is executed, and wait_for waits for that pattern to be seen, timing out after :max_retries retries.
-
seconds
Just wait this number of seconds no matter what.
Parameters
-
environment
An array of any additional environment variables you want to set for a command, such as ‘[ ’HOME=/root’, ‘MAIL=root@example.com’]‘. Note that if you use this to set PATH, it will override the `path` attribute. Multiple environment variables should be specified as an array.
This was copied from the Exec type.
-
max_retries
(defaults to: 119)
The number of times execution of the command should be retried. This many attempts will be made to execute the command until either an acceptable return code is returned or the regex is matched. Note that the timeout parameter applies to each try rather than to the complete set of tries.
This was copied from the Exec ‘tries’ parameter.
-
polling_frequency
(defaults to: 0.5)
The time to sleep in seconds between ‘tries’.
This was copied from the Exec ‘try_sleep’ parameter.
-
provider
The specific backend to use for this ‘wait_for` resource. You will seldom need to specify this — Puppet will usually discover the appropriate provider for your platform.
-
query (namevar)
The command to execute. The output of this command will be matched against the regex.
-
timeout
(defaults to: 300)
The maximum time the command (query) should take. If the command takes longer than the timeout, the command is considered to have failed and will be stopped. The timeout is specified in seconds. The default timeout is 300 seconds and you can set it to 0 to disable the timeout.
This was copied from the Exec type.