Use shell script to remotely log in to the server and modify the saltstack configuration and restart the service automation operation and maintenance tool SaltStack Build using jenkins+saltstack+sh to deploy projects to multiple servers

       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

Of course, it doesn't feel very good in this way, and it is more advanced to use python's fabric module to deal with it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325037642&siteId=291194637