Ansible Role logstash
This role installs and configures a Logstash server with support for multiple pipelines.
Note that this role does NOT let you specify a particular Logstash version. It simply installs the latest available Logstash version from the repos configured in the system. If you want or need to install a specific version, have a look at the linuxfabrik.lfops.repo_elasticsearch role (Logstash uses the Elasticsearch repository).
Mandatory Requirements
Enable the official elasticsearch repository. This can be done using the linuxfabrik.lfops.repo_elasticsearch role.
If you use the logstash playbook, this is automatically done for you.
Optional Role Variables
Variable |
Description |
Default Value |
|---|---|---|
|
ASCII-armored PEM CA certificate for TLS connections to Elasticsearch. Should match the CA used by Elasticsearch. |
unset |
|
Additional Java options passed to Logstash via |
|
|
The log level. Valid values are: |
|
|
A descriptive name for the node. |
|
|
Path to the directory where Logstash stores its data. |
|
|
Path to the directory where Logstash stores its logs. |
|
|
List of pipeline definitions. Subkeys:
|
|
|
Multiline string. Raw content which will be appended to the |
|
|
Enables or disables the logstash service, analogous to |
|
|
Controls the state of the logstash service, analogous to |
|
Example:
# optional
logstash__elasticsearch_ca_cert: '{{ lookup("ansible.builtin.file", "{{ inventory_dir }}/group_files/elasticsearch/ca.crt") }}'
logstash__java_opts: '-Djava.io.tmpdir={{ logstash__path_data }}/tmp'
logstash__log_level: 'info'
logstash__node_name: '{{ ansible_facts["nodename"] }}'
logstash__path_data: '/var/lib/logstash'
logstash__path_logs: '/var/log/logstash'
logstash__pipelines__host_var:
- pipeline_id: 'beats'
pipeline_workers: 4
content: |
input {
beats {
port => 5044
}
}
filter {
if [fields][type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGLINE}" }
}
}
}
output {
elasticsearch {
hosts => ["https://elasticsearch.example.com:9200"]
ssl_certificate_authorities => ["/etc/logstash/certs/ca.crt"]
user => "logstash_writer"
password => "${LOGSTASH_ES_PASSWORD}"
index => "beats-%{+YYYY.MM.dd}"
}
}
- pipeline_id: 'syslog'
queue_type: 'persisted'
queue_max_bytes: '2048mb'
content: |
input {
syslog {
port => 514
}
}
output {
elasticsearch {
hosts => ["https://elasticsearch.example.com:9200"]
ssl_certificate_authorities => ["/etc/logstash/certs/ca.crt"]
index => "syslog-%{+YYYY.MM.dd}"
}
}
- pipeline_id: 'old-pipeline'
state: 'absent'
logstash__raw: |-
config.reload.automatic: true
config.reload.interval: 3s
logstash__service_enabled: true
logstash__service_state: 'started'