Every now and then, I need to run some command on a few remote machines. I could open a session to each one and run the command there. Nothing wrong with that. But I use Ansible to manage my servers so there's a much more elegant way to do it.
ansible all --become --module-name shell --args "service rsyslog status" --inventory database.yml
(or, shorter, ansible all -b -m shell -a "service rsyslog status" -i database.yml)
And here we go!
db-01-master-pri | CHANGED | rc=0 >>
rsyslog start/running, process 19374
db-01-master-sec | CHANGED | rc=0 >>
rsyslog start/running, process 879
db-01-replica-01 | CHANGED | rc=0 >>
rsyslog start/running, process 19152
db-01-replica-02 | CHANGED | rc=0 >>
rsyslog start/running, process 19685
db-01-replica-03 | CHANGED | rc=0 >>
rsyslog start/running, process 7439