diff --git a/playbook/linux/elastic/install-metricbeat.yml b/playbook/linux/elastic/install-metricbeat.yml new file mode 100644 index 0000000..a9dd6b6 --- /dev/null +++ b/playbook/linux/elastic/install-metricbeat.yml @@ -0,0 +1,18 @@ + + +--- + +- name: Install Metricbeat + hosts: elasticClients + + tasks: + - name: Install Metricbeat + become: true + include_role: + name: luther38.metricbeat + vars: + kibana_host: 172.20.0.142 + elasticsearch_hosts: '["172.20.0.142:9200"]' + systemd_enable_service: true + systemd_restart_service: true + diff --git a/roles/luther38.metricbeat/defaults/main.yml b/roles/luther38.metricbeat/defaults/main.yml index 99e6285..5be7ce2 100644 --- a/roles/luther38.metricbeat/defaults/main.yml +++ b/roles/luther38.metricbeat/defaults/main.yml @@ -1,2 +1,12 @@ --- -# defaults file for luther38.metricbeat \ No newline at end of file +# defaults file for luther38.metricbeat + + +kibana_host: 127.0.0.1 + +# Example: '["172.0.0.1:9200"]' +elasticsearch_hosts: '["172.0.0.1:9200"]' + +systemd_enable_service: true + +systemd_restart_service: true diff --git a/roles/luther38.metricbeat/tasks/install-repo.yml b/roles/luther38.metricbeat/tasks/install-repo.yml index c4504a6..b11ff33 100644 --- a/roles/luther38.metricbeat/tasks/install-repo.yml +++ b/roles/luther38.metricbeat/tasks/install-repo.yml @@ -17,10 +17,7 @@ copy: dest: '/etc/apt/sources.list.d/elastic-7.x.list' content: "deb https://artifacts.elastic.co/packages/7.x/apt stable main" - # copy: - #src: elastic-7.x.list - # dest: /etc/apt/sources.list.d/ - # backup: yes + - name: Update Packages become: true diff --git a/roles/luther38.metricbeat/tasks/main.yml b/roles/luther38.metricbeat/tasks/main.yml index 126a7d9..71fb7bc 100644 --- a/roles/luther38.metricbeat/tasks/main.yml +++ b/roles/luther38.metricbeat/tasks/main.yml @@ -2,6 +2,5 @@ # tasks file for luther38.metricbeat - name: Install Metricbeat on Ubuntu - become: true - when:: ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Ubuntu' include: ubuntu.yml diff --git a/roles/luther38.metricbeat/tasks/ubuntu.yml b/roles/luther38.metricbeat/tasks/ubuntu.yml index ed2e0b9..e174e10 100644 --- a/roles/luther38.metricbeat/tasks/ubuntu.yml +++ b/roles/luther38.metricbeat/tasks/ubuntu.yml @@ -3,27 +3,35 @@ include: install-repo.yml - name: Install metricbeat from apt + become: true apt: name: metricbeat - name: Update config + become: true template: src: metricbeat.j2 dest: /etc/metricbeat/metricbeat.yml - name: enable system module + become: true shell: metricbeat modules enable system - name: systemd - daemon reload + become: true systemd: daemon_reload: yes - name: Enable service on system startup + when: systemd_enable_service == true + become: true systemd: name: metricbeat enabled: yes - name: systemd - restart Metricbeat + when: systemd_restart_service == true + become: true systemd: name: metricbeat state: restarted