1 --- 2 - hosts: web-server 3 remote_user: root 4 tasks: 5 - name: stop logstash 6 shell: PID=`ps -ef | grep logstash | grep -v grep | awk '{print $2}'`; if [ $PID ];then kill -9 $PID && echo "rm ok";fi 7 - name: rm old logstash 8 shell: rm -rf /data1/elk/logstash* 9 - name: cp new logstash 10 copy: src=/home/dev/playbook/conf.zip dest=/data1/elk/conf.zip 11 - name: unzip 12 shell: /usr/bin/unzip -o /data1/elk/conf.zip -d /data1/elk/logstash-6.5.1/ 13 - name: cp new logstash 14 copy: src=/home/dev/playbook/conf.zip dest=/data1/elk/conf.zip 15 - name: unzip 16 shell: /usr/bin/unzip -o /data1/elk/conf.zip -d /data1/elk/logstash-6.5.1/
![](https://img2018.cnblogs.com/blog/9/201812/9-20181214173852782-1654526997.png)