Ansible/roles/luther38.metricbeat/tasks/windows.yml

63 lines
1.7 KiB
YAML
Raw Normal View History

#https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.0.0-windows-x86_64.zip
2019-04-30 21:43:04 -07:00
# This will install metricbeat on a windows host.
---
- name: make tmp folder
2019-04-30 21:43:04 -07:00
win_file:
path: c:\tmp\
state: directory
- name: download metricbeat
win_get_url:
url: 'https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-{{ version }}-windows-x86_64.zip'
dest: 'C:\tmp\metricbeat-{{ version }}.zip'
2019-04-30 21:43:04 -07:00
force: no
- name: unzip metricbeat
win_unzip:
src: c:\tmp\metricbeat-{{ version }}.zip
dest: C:\tmp\metricbeat-{{ version }}\
creates: C:\tmp\metricbeat-{{ version }}\
2019-04-30 21:43:04 -07:00
- name: Copy metricbeat-{{ version }} folder
win_command: powershell.exe copy-item -Path 'c:\tmp\metricbeat-{{ version }}\metricbeat-{{ version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Metricbeat\'
2019-04-30 21:43:04 -07:00
args:
creates: C:\Program Files\Metricbeat\
- name: Update tmplate
2019-04-30 21:43:04 -07:00
win_template:
src: metricbeat.j2
dest: C:\Program Files\Metricbeat\metricbeat.yml
- name: Check if metricbeat service is installed
register: service
win_service:
name: metricbeat
#- debug: var=service
2019-04-30 21:43:04 -07:00
- name: Install Metricbeat service
when: service.exists == false
win_command: powershell.exe -ExecutionPolicy ByPass -File install-service-metricbeat.ps1
args:
chdir: C:\program files\metricbeat\
- name: check status of metricbeat service
register: service
win_service:
name: metricbeat
#- debug: var=service
- name: restart service
when: service.state == 'running'
win_service:
name: metricbeat
state: restarted
- name: start service
when: service.state == 'stopped'
win_service:
name: metricbeat
state: started