We using Boxen/Puppet to automate the build of our Mac development laptops, one step is to install rabbitmq, declare vhosts and add users.
But it takes little bit more time for rabbitmq to be ready for vhosts declaration and adding new users so we always have to run boxen twice.
Here is my logic
Checking if rabbitmq is ready by running following command
rabbitmqadmin list vhost
But we need rabbitmq installed and running so I added
require => Service['dev.rabbitmq']
If above commands worked then we know rabbit is accepting connections.
Here, let's put everything together.
exec { "Wait for rabbitmq":
command => "rabbitmqadmin list vhosts",
tries => 2,
try_sleep => 30,
require => Service['dev.rabbitmq']
}
dev::rabbitmq::vhost { '/clearvh':
require => Exec['Wait for rabbitmq']
}
dev::rabbitmq::user { 'clear': password => 'password' }
dev::rabbitmq::permission { [ 'guest', 'clear' ]: vhost => '/clearvh' }
}
That works well, but Exec {"Wait for rabbit"}
is getting called every time, even when dev::rabbit::vhost
is not. it would be idea if it is only called by dev::rabbitmq::vhost
.
Is that possible ?
Thanks