While waiting for VMs to provision...
Phil and I spent part of the day provisioning new virtual machines for some applications that we need to deploy which involves running a provisioning script and then opening another terminal and repeatedly trying to ssh into the box until it succeeds.
Eventually we got bored of doing that so we figured out a nice little one liner to use instead:
while :; do ssh 10.0.0.2; done
The ‘:’ is a bash noop and is defined like so:
null command [colon]. This is the shell equivalent of a "NOP" (no op, a do-nothing operation). It may be considered a synonym for the shell builtin true. The ":" command is itself a Bash builtin, and its exit status is true (0).
In this case it helps us to create an infinite loop which exits once an ssh session is established, meaning that the machine has its ssh daemon running and is ready to roll.
Since we’re using a puppet client/server setup we also want to run something on the puppet master to make sure that the client’s certificate has been signed.
Here we can use the ‘watch’ command to help us out:
watch "puppet cert list -a | grep new-client-new"
So we’ll see an empty screen until the client has sent a certificate request that’s been picked up by the puppet master and then we’ll see it come up.
As usual if you know any cooler ways to do the same things let me know in the comments!