7a32b5c9a9
The following options will reduce cluster pressure and generally improve search performance. Change-Id: I1619680db1fd595503f0845b182d6f6ce4c59f3c Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
239 lines
6.5 KiB
YAML
239 lines
6.5 KiB
YAML
---
|
|
- name: Install Logstash
|
|
hosts: elastic-logstash
|
|
become: true
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
vars:
|
|
temp_dir: /var/lib/logstash/tmp
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
pre_tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
tags:
|
|
- always
|
|
tasks:
|
|
- name: Set quarter memory fact
|
|
set_fact:
|
|
q_mem: "{{ (ansible_memtotal_mb | int) // 4 }}"
|
|
q_storage: "{{ ansible_processor_cores }}"
|
|
tags:
|
|
- always
|
|
|
|
- name: Set logstash facts
|
|
set_fact:
|
|
elastic_heap_size: "{{ ((q_mem | int) > 30720) | ternary(30720, q_mem) }}"
|
|
logstash_queue_size: "{{ (((q_storage | int) > 16) | ternary(16, q_storage) | int) * 1024 }}"
|
|
tags:
|
|
- always
|
|
|
|
- include_tasks: common_task_install_elk_repo.yml
|
|
|
|
- name: Configure systcl vm.max_map_count=262144 on container hosts
|
|
sysctl:
|
|
name: "vm.max_map_count"
|
|
value: "262144"
|
|
state: "present"
|
|
reload: "yes"
|
|
delegate_to: "{{ physical_host }}"
|
|
tags:
|
|
- sysctl
|
|
|
|
- name: Ensure mount directories exists
|
|
file:
|
|
path: "/openstack/{{ inventory_hostname }}/logstash"
|
|
state: "directory"
|
|
delegate_to: "{{ physical_host }}"
|
|
|
|
- name: logstash datapath bind mount
|
|
lxc_container:
|
|
name: "{{ inventory_hostname }}"
|
|
container_command: |
|
|
[[ ! -d "/var/lib/logstash" ]] && mkdir -p "/var/lib/logstash"
|
|
container_config:
|
|
- "lxc.mount.entry=/openstack/{{ inventory_hostname }}/logstash var/lib/logstash none bind 0 0"
|
|
delegate_to: "{{ physical_host }}"
|
|
when:
|
|
- physical_host != inventory_hostname
|
|
- container_tech | default('lxc') == 'lxc'
|
|
|
|
- name: Ensure Java is installed
|
|
apt:
|
|
name: openjdk-8-jre
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
install_recommends: yes
|
|
update_cache: yes
|
|
register: _apt_task
|
|
until: _apt_task is success
|
|
retries: 3
|
|
delay: 2
|
|
tags:
|
|
- package_install
|
|
|
|
- name: Ensure Logstash is installed
|
|
apt:
|
|
name: logstash
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: yes
|
|
register: _apt_task
|
|
until: _apt_task is success
|
|
retries: 3
|
|
delay: 2
|
|
notify:
|
|
- Enable and restart logstash
|
|
tags:
|
|
- package_install
|
|
|
|
- name: Create logstash systemd service config dir
|
|
file:
|
|
path: "/etc/systemd/system/logstash.service.d"
|
|
state: "directory"
|
|
group: "root"
|
|
owner: "root"
|
|
mode: "0755"
|
|
|
|
- name: Apply systemd options
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "/etc/systemd/system/logstash.service.d/{{ item.dest }}"
|
|
mode: "0644"
|
|
with_items:
|
|
- { src: "systemd.logstash-overrides.conf.j2", dest: "logstash-overrides.conf" }
|
|
notify:
|
|
- Enable and restart logstash
|
|
|
|
- name: Drop elasticsearch conf file
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
with_items:
|
|
- src: templates/jvm.options.j2
|
|
dest: /etc/logstash/jvm.options
|
|
- src: templates/99-elasticsearch-output.conf.j2
|
|
dest: /etc/logstash/conf.d/99-elasticsearch-output.conf
|
|
- src: templates/02-beats-input.conf.j2
|
|
dest: /etc/logstash/conf.d/02-beats-input.conf
|
|
- src: templates/logstash.yml.j2
|
|
dest: /etc/logstash/logstash.yml
|
|
notify:
|
|
- Enable and restart logstash
|
|
tags:
|
|
- config
|
|
|
|
- name: Create patterns directory
|
|
file:
|
|
name: "/opt/logstash/patterns"
|
|
owner: "logstash"
|
|
group: "logstash"
|
|
state: directory
|
|
tags:
|
|
- logstash-patterns
|
|
|
|
- name: Logstash Extra Patterns
|
|
template:
|
|
src: "{{ item }}"
|
|
dest: "/opt/logstash/patterns/{{ item }}"
|
|
owner: "logstash"
|
|
group: "logstash"
|
|
with_items:
|
|
- extras
|
|
when:
|
|
- logstash_deploy_filters
|
|
notify:
|
|
- Enable and restart logstash
|
|
tags:
|
|
- logstash-filters
|
|
- config
|
|
|
|
- name: Deploy Logstash configuration files
|
|
copy:
|
|
src: "files/{{ item }}"
|
|
dest: "/etc/logstash/conf.d/{{ item }}"
|
|
with_items:
|
|
- 02-general.conf
|
|
- 02-journald.conf
|
|
- 03-nova.conf
|
|
- 04-neutron.conf
|
|
- 05-glance.conf
|
|
- 06-cinder.conf
|
|
- 07-libvirt.conf
|
|
- 08-apache.conf
|
|
- 09-heat.conf
|
|
- 10-mysql.conf
|
|
- 10-syslog-filter.conf
|
|
- 11-auth.conf
|
|
- 12-logstash.conf
|
|
- 13-swift.conf
|
|
- 14-keystone.conf
|
|
- 16-elasticsearch.conf
|
|
- 17-rabbitmq.conf
|
|
- 18-ceph.conf
|
|
- 19-nginx.conf
|
|
- 20-magnum.conf
|
|
- 21-octavia.conf
|
|
- 98-traceback.conf
|
|
when:
|
|
- logstash_deploy_filters
|
|
notify:
|
|
- Enable and restart logstash
|
|
tags:
|
|
- logstash-filters
|
|
- config
|
|
|
|
- name: Run kafka output block
|
|
block:
|
|
- name: Copy kafka keystore into place
|
|
copy:
|
|
src: "{{ logstash_kafka_ssl_keystore_location }}"
|
|
dest: "/var/lib/logstash/{{ logstash_kafka_ssl_keystore_location | basename }}"
|
|
when:
|
|
- logstash_kafka_ssl_keystore_location is defined
|
|
|
|
- name: Copy kafka truststore into place
|
|
copy:
|
|
src: "{{ logstash_kafka_ssl_truststore_location }}"
|
|
dest: "/var/lib/logstash/{{ logstash_kafka_ssl_truststore_location | basename }}"
|
|
when:
|
|
- logstash_kafka_ssl_truststore_location is defined
|
|
|
|
- name: Deploy Logstash kafka configuration files
|
|
template:
|
|
src: "templates/99-kafka-output.conf"
|
|
dest: "/etc/logstash/conf.d/99-kafka-output.conf"
|
|
notify:
|
|
- Enable and restart logstash
|
|
when:
|
|
- logstash_kafka_options is defined
|
|
|
|
- name: Ensure logstash ownership
|
|
file:
|
|
path: /var/lib/logstash
|
|
owner: logstash
|
|
group: logstash
|
|
recurse: true
|
|
register: l_perms
|
|
until: l_perms is success
|
|
retries: 3
|
|
delay: 1
|
|
|
|
- name: Ensure logstash tmp dir
|
|
file:
|
|
path: "/var/lib/logstash/tmp"
|
|
state: directory
|
|
owner: "logstash"
|
|
group: "logstash"
|
|
mode: "0750"
|
|
|
|
handlers:
|
|
- name: Enable and restart logstash
|
|
systemd:
|
|
name: "logstash"
|
|
enabled: true
|
|
state: restarted
|
|
daemon_reload: true
|
|
|
|
tags:
|
|
- server-install
|