首页 > 代码库 > salt 执行shell 脚本 修改名字

salt 执行shell 脚本 修改名字

#!/bin/bash
#命令 匹配主机               执行模块  脚本路径,必须放在salt目录下  源主机名       修改的主机名
#salt tt_LD_LM_LC_1  cmd.script salt://init/rename.sh  ‘tt_LD_LM_LC_1 tt_LD_LM_1‘

echo "network"
sed -i "s#${1}#${2}#g" /etc/sysconfig/network
grep ${2} /etc/sysconfig/network

echo "zabbix_agentd.conf"
sed -i "s#${1}#${2}#g" /usr/local/zabbix/etc/zabbix_agentd.conf
grep ${2} /usr/local/zabbix/etc/zabbix_agentd.conf

echo "minion"
sed -i "s#${1}#${2}#g" /etc/salt/minion
grep ${2} /etc/salt/minion

echo "hosts"
sed -i "s#${1}#${2}#g" /etc/hosts
grep ${2} /etc/hosts
hostname ${2}

echo ‘/etc/init.d/salt-minion restart‘
/etc/init.d/salt-minion restart

 

salt 执行shell 脚本 修改名字