diff --git a/plays/metricbeat/metricbeat.yml b/plays/metricbeat/metricbeat.yml new file mode 100644 index 0000000..12bc425 --- /dev/null +++ b/plays/metricbeat/metricbeat.yml @@ -0,0 +1,81 @@ +###################### Metricbeat Configuration Example ####################### + +# This file is an example configuration file highlighting only the most common +# options. The metricbeat.reference.yml file from the same directory contains all the +# supported options with more comments. You can use it as a reference. +# +# You can find the full configuration reference here: +# https://www.elastic.co/guide/en/beats/metricbeat/index.html + +#========================== Modules configuration ============================ + +metricbeat.config.modules: + # Glob pattern for configuration loading + path: ${path.config}/modules.d/*.yml + + # Set to true to enable config reloading + reload.enabled: false + + # Period on which files under path should be checked for changes + #reload.period: 10s + +#================================ Outputs ===================================== + +# Configure what output to use when sending the data collected by the beat. + +#-------------------------- Elasticsearch output ------------------------------ +output.elasticsearch: + # Array of hosts to connect to. + hosts: ["https://cloud.denbi.de:443"] + allow_older_versions: true + + + # Optional protocol and basic auth credentials. + protocol: https + path: /elasticsearch/ + headers: + HOST: 'cloud.denbi.de' + username: ${METRICBEAT_USER} + password: ${METRICBEAT_PASSWORD} + + +#================================= Migration ================================== + +# This allows to enable 6.7 migration aliases +#migration.6_to_7.enabled: true + +metricbeat.modules: +- module: docker + metricsets: + - "container" + - "cpu" + - "diskio" + - "event" + - "healthcheck" + - "info" + - "memory" + - "network" + hosts: ["unix:///var/run/docker.sock"] + period: 45s + enabled: true +- module: system + metricsets: + - cpu # CPU usage + - load # CPU load averages + - memory # Memory usage + - network # Network IO + - process # Per process metrics + - process_summary # Process summary + - uptime # System Uptime + - socket_summary # Socket summary + - core # Per CPU core usage + - diskio # Disk IO + - filesystem # File system usage for each mountpoint + - fsstat # File system summary metrics + enabled: true + period: 60s + processes: ['.*'] + + # Configure the metric types that are included by these metricsets. + cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks. + core.metrics: ["percentages"] # The other available option is ticks. diff --git a/plays/metricbeat/restart-on-failure.conf b/plays/metricbeat/restart-on-failure.conf new file mode 100644 index 0000000..13b610d --- /dev/null +++ b/plays/metricbeat/restart-on-failure.conf @@ -0,0 +1,4 @@ +[Service] +Restart=on-failure +RestartSec=20 +StartLimitIntervalSec=0 diff --git a/plays/metricbeat/setup_metricbeat.yml b/plays/metricbeat/setup_metricbeat.yml new file mode 100644 index 0000000..024b9b0 --- /dev/null +++ b/plays/metricbeat/setup_metricbeat.yml @@ -0,0 +1,46 @@ +- name: Setup metricbeat + hosts: all + become: yes + vars_files: + - setup_metricbeat_variables.yml + - ../general_variables.yml + + tasks: + + - name: Download and install metricbeat.deb + apt: + deb: "{{ metricbeat.DOWNLOAD_URL }}" + tags: [ 'metricbeat' ] + + - name: Copy metricbeat config file + copy: + src: "{{ general.REPO_PATH }}plays/metricbeat/metricbeat.yml" + dest: "{{ metricbeat.CONFIG_FILE_PATH }}/metricbeat.yml" + remote_src: True + tags: [ 'production', 'dev', 'post-release', 'never' ] + + - name: Create metricbeat dropin dir + file: + state: directory + path: "{{ metricbeat.OVERRIDE_CONFIG_PATH }}" + recurse: yes + tags: [ 'metricbeat' ] + + - name: Copy metricbeat override config file + copy: + src: "{{ general.REPO_PATH }}plays/metricbeat/restart-on-failure.conf" + dest: "{{ metricbeat.OVERRIDE_CONFIG_PATH }}/restart-on-failure.conf" + remote_src: True + tags: [ 'metricbeat' ] + + - name: Just force systemd to reread configs (2.4 and above) + ansible.builtin.systemd: + daemon_reload: yes + tags: [ 'metricbeat' ] + + + - name: Start Metricbeat service + service: + name: metricbeat + state: restarted + tags: [ 'metricbeat' ] diff --git a/plays/metricbeat/setup_metricbeat_variables.yml b/plays/metricbeat/setup_metricbeat_variables.yml new file mode 100644 index 0000000..9f35ad1 --- /dev/null +++ b/plays/metricbeat/setup_metricbeat_variables.yml @@ -0,0 +1,4 @@ +metricbeat: + DOWNLOAD_URL: "https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-8.12.0-amd64.deb" + CONFIG_FILE_PATH: /etc/metricbeat + OVERRIDE_CONFIG_PATH: /etc/systemd/system/metricbeat.service.d diff --git a/plays/setup_client.yml b/plays/setup_client.yml index 8b62c94..d255bb5 100644 --- a/plays/setup_client.yml +++ b/plays/setup_client.yml @@ -24,7 +24,7 @@ - name: Check if ca pem file exists already stat: - path: "{{ client.PERSISTENT_PATH }}/ca.pem" + path: "{{ client.PERSISTENT_PATH }}/CA.pem" register: stat_ca_pem tags: always