patternMinor
Ansible ad-hoc command to reboot servers in serial with a pause
Viewed 0 times
rebootserverswithpauseserialcommandansiblehoc
Problem
How do I go through all hosts in an Ansible inventory in serial with an Ansible ad-hoc and reboot servers with a specified number of seconds in between each reboot?
I am looking for something similar to:
It should have a pause and run in serial.
I am looking for something similar to:
ansible -i inventory nodes -a "/sbin/reboot" It should have a pause and run in serial.
Solution
@Argyle explained the
I suggest you have a look at the
A quick example that will reboot all your nodes one by one waiting for each to be fully booted before moving to the next one.
Pass needed parameters to the module depending on your requirements with the
--fork 1 trick to achieve a serial run.I suggest you have a look at the
reboot module that might be better suited than running a command directly. A quick example that will reboot all your nodes one by one waiting for each to be fully booted before moving to the next one.
ansible -i inventory nodes --forks 1 -m rebootPass needed parameters to the module depending on your requirements with the
-a option.Code Snippets
ansible -i inventory nodes --forks 1 -m rebootContext
StackExchange DevOps Q#10542, answer score: 5
Revisions (0)
No revisions yet.