Skip to content

Instantly share code, notes, and snippets.

@jloehel
Created July 9, 2020 02:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jloehel/c9c7fac7a1e9e6bd732268e1f1bea9b7 to your computer and use it in GitHub Desktop.
Save jloehel/c9c7fac7a1e9e6bd732268e1f1bea9b7 to your computer and use it in GitHub Desktop.
Ansible - Logstash - Role
---
- block:
- name: Install apt-transport-https
apt:
name: apt-transport-https
state: present
- name: Adding Adoptopenjdk's Signing Key
apt_key:
url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
state: present
- name: Adding Elastic’s Signing Key
apt_key:
id: 46095ACC8548582C1A2699A9D27D666CD88E42B4
url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
state: present
- name: Adding Elasitc's repository
apt_repository:
repo: deb https://artifacts.elastic.co/packages/7.x/apt stable main
state: present
filename: elastic-7.x
- name: Adding Adoptopenjdk's repository
apt_repository:
repo: deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main
state: present
filename: adoptopenjdk
- name: Install Adoptopenjdk
apt:
name: adoptopenjdk-8-hotspot
state: present
- name: Set new Adoptopenjdk as standard JAVA
alternatives:
name: java
path: /usr/lib/jvm/adoptopenjdk-8-hotspot-arm64/bin/java
- name: Install logstash
apt:
name: logstash
state: present
- name: Stop and enable the logstash service
service:
name: logstash
state: stopped
enabled: yes
tags:
- install
- logstash
- debian
- apt
- block:
- name: Install zip and unzip
apt:
name: "{{ packages }}"
update_cache: yes
state: present
vars:
packages:
- zip
- unzip
- name: Create /tmp/jruby
file:
state: directory
path: /tmp/jruby
- name: Extract jruby-complete
unarchive:
src: /usr/share/logstash/logstash-core/lib/jars/jruby-complete-9.2.11.1.jar
dest: /tmp/jruby/
remote_src: yes
- name: Modify jruby-complete
copy:
owner: logstash
group: logstash
src: /tmp/jruby/META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/aarch64-linux/types.conf
dest: /tmp/jruby/META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/aarch64-linux/platform.conf
remote_src: yes
- name: Pack jruby-complete
archive:
format: zip
dest: /usr/share/logstash/logstash-core/lib/jars/jruby-complete-9.2.11.1.jar
path:
- /tmp/jruby/*
- name: Remove tmp dir
file:
path: /tmp/jruby/
state: absent
tags:
- install
- logstash
- jffi
- git
- block:
- name: Create templates dir for logstash
file:
path: /etc/logstash/templates
state: directory
owner: root
group: root
mode: 0755
- name: Copy configuration for the xxx
template:
src: xxx.j2
dest: /etc/logstash/conf.d/xxx.conf
owner: root
group: root
mode: "0644"
- name: Config | jvm heap size min
lineinfile:
dest: /etc/logstash/jvm.options
regexp: '^-Xms256m'
state: present
line: -Xms256m
- name: Config | jvm heap size max
lineinfile:
dest: /etc/logstash/jvm.options
regexp: '-Xmx1g'
state: present
line: -Xmx512m
tags:
- configuration
- logstash
- block:
- name: Start the logstash service
service:
name: logstash
state: started
tags:
- start
- logstash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment