Ansible/playbook/linux/elastic/config-win-metricbeat.yml

57 lines
1.7 KiB
YAML
Raw Normal View History

---
# This will install all the client parts needed for elastic to monitor client computers
- name: download metricbeat
win_get_url:
url: '{{ url_metricbeat }}'
dest: 'C:\temp\metricbeat-{{ elastic_version }}.zip'
force: no
- name: unzip heartbeat
win_unzip:
src: c:\temp\metricbeat-{{ elastic_version }}.zip
dest: C:\temp\metricbeat-{{ elastic_version }}\
creates: C:\temp\metricbeat-{{ elastic_version }}\
- name: Copy metricbeat-{{ elastic_version }} folder
win_command: powershell.exe copy-item -Path 'c:\temp\metricbeat-{{ elastic_version }}\metricbeat-{{ elastic_version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Metricbeat\'
args:
creates: C:\Program Files\Metricbeat\
- name: Update template
win_template:
src: metricbeat.j2
dest: C:\Program Files\Metricbeat\metricbeat.yml
- name: Check if metricbeat service is installed
register: service_metricbeat
win_service:
name: metricbeat
#- debug: var=service_metricbeat
- name: Install Metricbeat service
win_command: powershell.exe -ExecutionPolicy ByPass -File install-service-metricbeat.ps1
args:
chdir: C:\program files\metricbeat\
when: service_metricbeat.exists == false
- name: check status of metricbeat service
register: service_metricbeat
win_service:
name: metricbeat
#- debug: var=service_metricbeat
- name: restart service
win_service:
name: metricbeat
state: restarted
when: service_metricbeat.state == 'started'
- name: start service
win_service:
name: metricbeat
state: started
when: service_metricbeat.state == 'stopped'