forked from evolix/ansible-roles
956ecd4700
The behaviour of the `include` module is badly defined (it try to choose between statically importing the tasks and dynamically including them) and can cause problems depending on any number of constraints (mostly if it choose the wrong behaviour). Replace it with the `import_tasks` (always statically import tasks) unless the `include` is in a loop in which case we replace it with `include_tasks` (always dynamically include tasks).
111 lines
2.2 KiB
YAML
111 lines
2.2 KiB
YAML
---
|
|
|
|
- name: APT https transport is enabled
|
|
apt:
|
|
name: apt-transport-https
|
|
state: present
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Look for legacy apt keyring
|
|
stat:
|
|
path: /etc/apt/trusted.gpg
|
|
register: _trusted_gpg_keyring
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Elastic embedded GPG key is absent
|
|
apt_key:
|
|
id: "D88E42B4"
|
|
keyring: /etc/apt/trusted.gpg
|
|
state: absent
|
|
when: _trusted_gpg_keyring.stat.exists
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Elastic GPG key is installed
|
|
copy:
|
|
src: elastic.asc
|
|
dest: /etc/apt/trusted.gpg.d/elastic.asc
|
|
force: yes
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Elastic sources list is available
|
|
apt_repository:
|
|
repo: "deb https://artifacts.elastic.co/packages/{{ elastic_stack_version | mandatory }}/apt stable main"
|
|
filename: elastic
|
|
state: present
|
|
update_cache: yes
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Logstash is installed
|
|
apt:
|
|
name: logstash
|
|
state: present
|
|
tags:
|
|
- logstash
|
|
- packages
|
|
|
|
- name: Logstash service is enabled
|
|
systemd:
|
|
name: logstash
|
|
enabled: yes
|
|
tags:
|
|
- logstash
|
|
|
|
- name: JVM Heap size (min) is set
|
|
lineinfile:
|
|
dest: /etc/logstash/jvm.options
|
|
regexp: "^-Xms"
|
|
line: "-Xms{{ logstash_jvm_xms }}"
|
|
tags:
|
|
- logstash
|
|
- config
|
|
|
|
- name: JVM Heap size (max) is set
|
|
lineinfile:
|
|
dest: /etc/logstash/jvm.options
|
|
regexp: "^-Xmx"
|
|
line: "-Xmx{{ logstash_jvm_xmx }}"
|
|
tags:
|
|
- logstash
|
|
- config
|
|
|
|
- name: Add a configuration
|
|
template:
|
|
src: "{{ item }}"
|
|
dest: /etc/logstash/conf.d/logstash.conf
|
|
owner: logstash
|
|
group: logstash
|
|
mode: "0640"
|
|
force: "{{ logstash_config_force | bool }}"
|
|
loop: "{{ query('first_found', templates) }}"
|
|
vars:
|
|
templates:
|
|
- "templates/logstash/logstash.{{ inventory_hostname }}.conf.j2"
|
|
- "templates/logstash/logstash.{{ host_group | default('all') }}.conf.j2"
|
|
- "templates/logstash/logstash.default.conf.j2"
|
|
- "templates/logstash.default.conf.j2"
|
|
register: logstash_template
|
|
tags:
|
|
- logstash
|
|
- config
|
|
|
|
- debug:
|
|
var: logstash_template
|
|
verbosity: 1
|
|
|
|
- import_tasks: logs.yml
|
|
|
|
- import_tasks: tmpdir.yml
|