main.yml
890 Bytes
---
# tasks file for filebeat
- name: Init filebeat folders
shell: mkdir -p /etc/filebeat /Data/logs/filebeat
- name: ensure filebeat is uninstalled
yum:
name: filebeat
state: absent
- name: replace filebeat binary file with version 5.6.4
copy:
src: "filebeat-5.6.4"
dest: "/usr/sbin/filebeat"
mode: 0755
- name: copy nginx filebeat config files and start filebeat
template:
src: "{{ item }}.yml"
dest: "/etc/filebeat/filebeat-{{ item }}.yml"
with_items:
- nginx-access
- ufo-nginx-access
- name: restart filebeat
shell: ps aux|grep filebeat-"{{ item }}".yml|grep -v grep|head -n1|awk '{print $2}'|xargs -i kill -9 {} ; nohup filebeat -c /etc/filebeat/filebeat-"{{ item }}".yml -path.data /Data/logs/filebeat/data/"{{ item }}" -path.logs /Data/logs/filebeat/logs/"{{ item }}"&
with_items:
- nginx-access
- ufo-nginx-access