修改Hostname值

2022-06-14 19:45:22 浏览数 (2)

代码语言:javascript复制
#!/bin/bash 

hostname=`hostname`
old_hostname=`grep -Ev '^$|^#' /etc/zabbix/zabbix_agentd.conf  | grep Hostname`
sed -i "s#$old_hostname#Hostname=$hostname#g" /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent

下发:

代码语言:javascript复制
ansible -i hosts.work  new-openstack  -m shell -a "netstat -lntup | grep 10050"
ansible -i hosts.work  new-openstack-ceph  -m shell -a "cat /etc/zabbix/zabbix_agentd.conf | grep 172.24.15.122"
ansible -i hosts.work  new-openstack -m copy -a "src=/root/test.sh dest=/tmp/test.sh"
ansible -i hosts.work  new-openstack  -m shell -a "sh /tmp/test.sh"

标题:修改Hostname值

作者:cuijianzhe

地址:https://cloud.tencent.com/developer/article/2022888

0 人点赞