How do you restart a service on a group with an ad-hoc command?
BeginnerProductionRapid-Fire Commands
Answer
ansible web -i inventories/prod -b -m ansible.builtin.systemd_service \
-a "name=nginx state=restarted" --forks 5
-b enables become. Keep --forks low for restarts so you do not take the whole tier down at once; for a real rolling restart, use a playbook with serial.
More on Rapid-Fire Commands
How do you see which hosts a playbook would run against, without running it?BeginnerHow do you list the tasks and tags a playbook contains?BeginnerHow do you inspect the inventory structure and a host's variables?BeginnerHow do you resume a playbook from a specific task or step through it?BeginnerHow do you re-run a playbook only on the hosts that failed?IntermediateHow do you check the value a variable resolves to on a specific host?Intermediate