---
logstash_id: "{{ inventory_hostname }}-logstash"

elastic_docker:
  {
    volumes: [{ name: "{{ logstash_id }}-data" }],
    services:
      [
        {
          name: "{{ logstash_id }}",
          image_name: "{{ logstash_image_name }}",
          image_version: "{{ elastic_logstash_version }}",
          environment:
            [
              'log.format: "json"',
              'node.name: "{{ logstash_id }}"',
              'config.reload.automatic: "true"',
              "pipeline.ecs_compatibility: v1",
              'pipeline.ordered: "false"',
              'xpack.monitoring.enabled: "true"',
              'xpack.monitoring.elasticsearch.username: "{{ elastic_admin_username }}"',
              'xpack.monitoring.elasticsearch.password: "{{ elastic_admin_password }}"',
              "xpack.monitoring.elasticsearch.hosts: https://{{ shared_service_elastic_stack_01_hostname }}:9200",
              "xpack.monitoring.elasticsearch.ssl.certificate_authority: /usr/share/logstash/config/certificates/ca/ca.crt",
            ],
          volumes:
            [
              '"{{ logstash_id }}-data:/usr/share/logstash/data"',
              '"./config/logstash/pipeline:/usr/share/logstash/pipeline:ro"',
              '"./certs:/usr/share/logstash/config/certificates:ro"',
            ],
          extra_hosts: "{{ elastic_extra_hosts | default([]) }}",
          ports:
            [{ external: "{{ service_port_logstash }}", internal: "5044" }],
        },
      ],
  }
