KeiruaProd

I help my clients acquire new users and make more money with their web businesses. I have ten years of experience with SaaS projects. If that’s something you need help with, we should get in touch!
< Back to article list

Running a shell command on multiple machines using ansible

I always forget how to run a command on multiples machines:

# Running a shell command on a bunch of machines
ansible -i inventories/dev webservers -m shell -a 'systemctl stop delayed_job' --become

It’s also useful to be able to run a task by tag:

# Listing what will be run
ansible-playbook -t delayed_job -i inventories/dev webservers.yml --list-tasks
# dry-run of a task 
ansible-playbook -t delayed_job -i inventories/dev webservers.yml --check --diff
# Really running a task
ansible-playbook -t delayed_job -i inventories/dev webservers.yml

You May Also Enjoy