Recently, the company added 40 servers for the last activity function. Although the servers can be managed uniformly through saltstack ( built by the automated operation and maintenance tool SaltStack ), the project can be released uniformly through jenkins + saltstack ( using jenkins + saltstack + sh to deploy projects to multiple Servers ), but before that, you need to change the saltstack configuration files of these 40 servers. You can't do it manually for each server (well, I worked for a long time before writing this article, and I really did it manually. yes, pit)
Because the public key has been added, you can log in directly without a password
#!/bin/sh ip=$1 ssh root@${ip} "sed -i 's/id: shop02/id: active30/g' /etc/salt/minion && service salt-minion restart"
The script is mainly
1. Log in to the ${ip} server.
2. Replace the string id: shop02 with id: active30 in the /etc/salt/minion file
3. Restart the salt-minion service