Skip to content

blacklist only the current beat #12

@github-actions

Description

@github-actions

blacklist only the current beat
beat executable even to create the keystore will fail.

# TODO blacklist only the current beat

---

- name: "{{ beats_flavor }}: Install dependencies"
  apt:
    name: "{{ _beats_packages['all']
              | union(_beats_packages[beats_flavor]
                      | default([])
                     )
           }}"

- name: "{{ beats_flavor }}: Install https apt transport"
  apt:
    name: apt-transport-https

- name: "{{ beats_flavor }}: Install using elastic repository"
  block:
    - name: "{{ beats_flavor }}: Add upstream repo key"
      apt_key:
        url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
        id: 46095ACC8548582C1A2699A9D27D666CD88E42B4
        # validate_certs: false

    - name: "{{ beats_flavor }}: Add upstream beats repository"
      apt_repository:
        repo: "deb https://artifacts.elastic.co/packages/{{
                beats_major_version }}.x/apt stable main"

    - name: "{{ beats_flavor }}: Install {{ beats_flavor }}"
      apt:
        name: "{{ beats_flavor
                  if beats_flavor != 'heartbeat'
                  else 'heartbeat-elastic'
                }}={{ beats_major_version }}.{{
                      beats_minor_version | string }}{{
                      '' if beats_minor_version == '*' else '.' + beats_patch_version | string
                }}"
        update_cache: true
      notify: beats-restart-service

    # TODO blacklist only the current beat
    - name: "{{ beats_flavor }}: Disable automatic updates"
      copy:
        content: |
          Unattended-Upgrade::Package-Blacklist {
            "auditbeat";
            "heartbeat";
            "filebeat";
            "journalbeat";
            "metricbeat";
            "packetbeat";
          };
        dest: /etc/apt/apt.conf.d/55beats-disable
        mode: 0o644
      when: beats_disable_auto_update | bool
  when:
    - beats_flavor != 'winlogbeat'
    - beats_full_version is version(beats_user_version, '<')

# These two are needed because if the config file does not exist, running the
# beat executable even to create the keystore will fail.
- name: "{{ beats_flavor }}: Create config dir"
  file:
    path: "{{ beats_path_config }}"
    mode: 0o755
    state: directory

- name: "{{ beats_flavor }}: Check if config file exists"
  stat:
    path: "{{ beats_path_config }}/{{ beats_flavor }}.yml"
  register: _beats_config_file_exists

- name: "{{ beats_flavor }}: Touch config file"
  file:
    path: "{{ beats_path_config }}/{{ beats_flavor }}.yml"
    mode: 0o644
    state: touch
  when: not _beats_config_file_exists.stat.exists | bool
        or _beats_config_file_exists.stat.mode != "0644"

- name: Load winlogbeat install tasks for Linux
  include_tasks: "Debian-winlogbeat.yml"
  when:
    - beats_full_version is version(beats_user_version, '<')

d6db78c5d0a746c668a1277010f2ae2d30dff564

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions