From fde241d31b720321c9431728f145c8fd558f7970 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 30 Apr 2019 21:43:04 -0700 Subject: [PATCH] Added Windows support for metricbeat --- playbook/linux/elastic/install-metricbeat.yml | 2 -- roles/luther38.metricbeat/defaults/main.yml | 8 ++++- roles/luther38.metricbeat/tasks/main.yml | 4 +++ roles/luther38.metricbeat/tasks/windows.yml | 32 +++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 roles/luther38.metricbeat/tasks/windows.yml diff --git a/playbook/linux/elastic/install-metricbeat.yml b/playbook/linux/elastic/install-metricbeat.yml index a9dd6b6..8643cd0 100644 --- a/playbook/linux/elastic/install-metricbeat.yml +++ b/playbook/linux/elastic/install-metricbeat.yml @@ -1,5 +1,3 @@ - - --- - name: Install Metricbeat diff --git a/roles/luther38.metricbeat/defaults/main.yml b/roles/luther38.metricbeat/defaults/main.yml index 5be7ce2..5a87f4e 100644 --- a/roles/luther38.metricbeat/defaults/main.yml +++ b/roles/luther38.metricbeat/defaults/main.yml @@ -1,12 +1,18 @@ --- # defaults file for luther38.metricbeat - +# Defines the kibana host we will send data to kibana_host: 127.0.0.1 # Example: '["172.0.0.1:9200"]' elasticsearch_hosts: '["172.0.0.1:9200"]' +# tells ansible to enable the service on startup systemd_enable_service: true +# Tells ansible to restart the service after everything has been done systemd_restart_service: true + +# Defines the version of metricbeat to install. +# Currently used for Windows +version: 7.0.0 diff --git a/roles/luther38.metricbeat/tasks/main.yml b/roles/luther38.metricbeat/tasks/main.yml index 71fb7bc..ff1f622 100644 --- a/roles/luther38.metricbeat/tasks/main.yml +++ b/roles/luther38.metricbeat/tasks/main.yml @@ -4,3 +4,7 @@ - name: Install Metricbeat on Ubuntu when: ansible_distribution == 'Ubuntu' include: ubuntu.yml + +- name: Install Metricbeat on Windows + when: ansible_distribution == 'Windows' + include: windows.yml diff --git a/roles/luther38.metricbeat/tasks/windows.yml b/roles/luther38.metricbeat/tasks/windows.yml new file mode 100644 index 0000000..715e5b3 --- /dev/null +++ b/roles/luther38.metricbeat/tasks/windows.yml @@ -0,0 +1,32 @@ + +# This will install metricbeat on a windows host. +--- +- name: make temp folder + win_file: + path: c:\tmp\ + state: directory + +- name: download metricbeat + win_get_url: + url: '{{ url_metricbeat }}' + dest: 'C:\temp\metricbeat-{{ version }}.zip' + force: no + +- name: unzip metricbeat + win_unzip: + src: c:\temp\metricbeat-{{ version }}.zip + dest: C:\temp\metricbeat-{{ version }}\ + creates: C:\temp\metricbeat-{{ version }}\ + +- name: Copy metricbeat-{{ version }} folder + win_command: powershell.exe copy-item -Path 'c:\temp\metricbeat-{{ version }}\heartbeat-{{ 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: Install Metricbeat service + win_command: powershell.exe -ExecutionPolicy ByPass -File 'C:\Program Files\Metricbeat\install-service-metricbeat.ps1'