ansible-playbook 部署zabbix agent

 

 

cat socat.service
[Unit]
Description=socat Server
Requires=network.target
After=network.target

[Service]
Type=simple
PIDFile=/tmp/socat.pid
KillMode=control-group
ExecStart=/bin/socat -d -d TCP-LISTEN:8001,fork,bind=127.0.0.1,range=192.168.1.1/16 UNIX:/var/run/docker.sock
ExecStop=/usr/bin/pkill -9 socat 
Restart=always
RestartSec=5s
User=root
Group=root

[Install]
WantedBy=multi-user.target

 


cat socat.yml --- #固定格式 - hosts: imagetest #定义需要执行主机 gather_facts: false remote_user: root #远程用户 tasks: - name: install socat package yum: name=socat - name: copy socat.service template: src=./socat.service dest=/etc/systemd/system/ - name: sed ip command: sed -i 's/127.0.0.1/{{ ansible_ssh_host }}/g' /etc/systemd/system/socat.service - name: systemctl daemon-reload command: systemctl daemon-reload - name: restart socat.service command: systemctl restart socat.service - name: enable socat.service command: systemctl enable socat.service

 

ansible-playbook -i docker all -C socat.yml
ansible-playbook  -C socat.yml

 

posted @ 2022-06-21 10:50  Hello_worlds  阅读(84)  评论(0编辑  收藏  举报