When you have a bunch of servers that are configured the same and need to run the same task on them you will need a tool that does that. There are several Open Source tools.
I was asked to write such a script but quickly fell upon several really popular scripts.
The perfect one for this task is clush or clustershell which uses python. You can install it with pip, yum, apt or source code. http://clustershell.readthedocs.io/en/latest/install.html
to install clush I did:
sudo apt install clustershell
In order for clush to work you need to be able to login without a password. This was pretty easy since I was using EC2 cloud servers that already come with a key. I setup
You can put the key into .ssh
First edit .ssh/config
You can organize this file with domains using wildcards like *.charming.click. So you can use the correct key for the correct machines. I set it with *
You can put a list of such servers with their associated identity files.
Thats it your ready to control as many servers as you like from a command prompt.
type in the username@theservername with commas (no space) between names
clush -w firstname.lastname@example.org,email@example.com
Then give any command that you like. It is not a good idea to run interactive programs like vim editor. Instead edit your file locally and move it around with clush.
Clush also has a copy command for this purpose
clush -v -w list,of,servers -c /local/file /destination/on/servers
It is very powerful and has lots of config options. See: http://clustershell.readthedocs.io/en/latest/config.html