---

- name: Install packages
  yum:
    name:
      - java-11-openjdk-headless
      - logstash
    state: present

- name: Add sysconfig file
  template:
    src: logstash_sysconfig.j2
    dest: /etc/sysconfig/logstash
  notify: Restart logstash

- name: Copy Logstash configs to /etc
  copy:
    remote_src: true
    src: /opt/rocknsm/ecs-configuration/logstash/conf.d/
    dest: "/etc/logstash/conf.d/"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"


- name: Template input configs
  template:
    src: "{{ item.src }}"
    dest: "/etc/logstash/conf.d/{{ item.dest }}"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"
    mode: 0640
  notify: Restart logstash
  when: logstash_configs is defined
  with_items: "{{ logstash_configs }}"

- name: Template Elasticsearch output for Logstash
  template:
    src: "{{ item }}.j2"
    dest: "/etc/logstash/conf.d/{{ item }}.conf"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"
    mode: 0640
  notify: Restart logstash
  loop:
    - logstash-9999-output-elasticsearch.conf

- name: Enable and start Logstash
  service:
    name: logstash
    state: "started"
    enabled: "{{ 'True' if rock_services | selectattr('name', 'equalto', 'logstash') | map(attribute='enabled') | bool else 'False' }}"

---

- name: Install packages
  yum:
    name:
      - java-11-openjdk-headless
      - logstash
    state: present

- name: Add sysconfig file
  template:
    src: logstash_sysconfig.j2
    dest: /etc/sysconfig/logstash
  notify: Restart logstash

- name: Copy Logstash configs to /etc
  copy:
    remote_src: true
    src: {{ rock_module_dir }}}}/ecs-configuration/logstash/conf.d/
    dest: "/etc/logstash/conf.d/"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"


- name: Template input configs
  template:
    src: "{{ item.src }}"
    dest: "/etc/logstash/conf.d/{{ item.dest }}"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"
    mode: 0640
  notify: Restart logstash
  when: logstash_configs is defined
  with_items: "{{ logstash_configs }}"

- name: Template Elasticsearch output for Logstash
  template:
    src: "{{ item }}.j2"
    dest: "/etc/logstash/conf.d/{{ item }}.conf"
    owner: "{{ logstash_user }}"
    group: "{{ logstash_group }}"
    mode: 0640
  notify: Restart logstash
  loop:
    - logstash-9999-output-elasticsearch.conf

- name: Enable and start Logstash
  service:
    name: logstash
    state: "started"
    enabled: "{{ 'True' if rock_services | selectattr('name', 'equalto', 'logstash') | map(attribute='enabled') | bool else 'False' }}"

Use variable for correct logstash pipeline configs
Use variable for correct logstash pipeline configs
