A pseudo resource type to wait for a condition to become satisfied.

Bastian Krol



229,511 latest version

3.5 quality score

Version information

  • 0.3.0 (latest)
  • 0.2.0
  • 0.1.0
  • 0.0.1
released Nov 21st 2014
This module has been deprecated by its author since Nov 27th 2018.

The reason given was: This module has now been deprecated in favor of the heini/wait_for module.

The author has suggested heini-wait_for as its replacement.

Start using this module

Tags: shell, cmd, wait, cmdexe


basti1302/wait_for — version 0.3.0 Nov 21st 2014


A pseudo resource type for puppet that enables you to wait for certain conditions. You can use shell commands to query arbitrary things and either react on the exit code or match the output of the command against a regular expression.

Warning: By using this module you are leaving the pure puppet philosophy - this is not really a resource which's state can updated/kept in synch by puppet. Also, you might be tempted to use this module to work around issues that should be fixed by other means.

That said, there are situations where this might come in handy - for example, when you need to start/stop services in some asynchronous fashion. Puppet's basic assumption is, that when the code to update a resource has finished, then the resource is in the desired state, period. In the real world, this is not always the case, especially if you are doing a lot of things via exec resources and even more if the exec commandforks or kicks off a process which needs some time to come up.


Either install the latest release from puppet forge:

puppet module install basti1302-wait_for

or install the current head from the git repository by going to your puppet modules folder and do

git clone git@github.com:basti1302/puppet-wait-for.git wait_for

It is important that the folder where this module resisdes is named wait_for, not puppet-wait-for.


include wait_for

# Example for Linux: This waits until the sshd service has started.
# Remark: You do not need to do this if you use a proper service resource
# to start the service. After all, this is just an example.
wait_for { 'service sshd status':
  regex    => '.*is running.*',

# Example for Windows: This waits until the MySQL5 service has started.
# Remark: You do not need to do this if you use a proper service resource
# to start the service. After all, this is just an example.
wait_for { 'sc query MySQL5':
  regex   => '.*STATE\s*:\s*4\s*RUNNING.*',

# This will wait until the command returns with exit code 42. Of course,
# this will never happen for the echo command, so this example will always
# fail. If you replace 42 with 0, it will succeed immediately, without
# waiting.
wait_for { 'echo foobar':
  exit_code         => 42,
  polling_frequency => 0.3,
  max_retries       => 5,

# This will simply wait for one minute
wait_for { 'a_minute':
  seconds => 60,

# This is actually illegal because one of regex or exit_code has to be specified.
# wait_for { 'echo abc':
# }

# This is also illegal because only one of regex or exit_code can be specified.
# wait_for { 'echo xyz':
#   regex             => 'whatever',
#   exit_code         => 0,
# }

# The name of the namevar (which is the command to query the current state) is query, by the way.
wait_for { 'without implicit namevar':
  query   => 'echo foobar',
  regex   => 'foobar',