Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Add tasks to allow Logstash opening of privileged ports
Browse files Browse the repository at this point in the history
  • Loading branch information
widhalmt committed Dec 1, 2020
1 parent b7820b4 commit 28e94f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ logstash_release: 7
logstash_manage_java: true
logstash_config_backup: no
logstash_manage_yaml: true
logstash_privileged: false

# config items in yaml file #

Expand Down
5 changes: 4 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# handlers file for logstash
- name: Restart Logstash
- name: restart Logstash
service:
name: logstash
state: restarted
Expand All @@ -11,3 +11,6 @@
name: logstash
state: restarted
when: not logstash_config_autoreload and logstash_enable | bool

- name: call ldconfig
command: "/sbin/ldconfig"
3 changes: 3 additions & 0 deletions tasks/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
tags:
- security

- import_tasks: privileged.yml
when: logstash_privileged | bool

- name: Start Logstash
service:
name: logstash
Expand Down
18 changes: 18 additions & 0 deletions tasks/privileged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: allow Logstash opening of privileged ports
shell: "setcap 'cap_net_bind_service=+ep' $(readlink -f /usr/bin/java)"
changed_when: false
- name: Find libjli library
shell: 'set -o pipefail && find / -name libjli.so -exec dirname {} \; | head -1'
changed_when: false
register: libjli_path
- name: Enable ldconfig to search for libjli
template:
src: java-libjli.conf.j2
dest: /etc/ld.so.conf.d/java-libjli.conf
owner: root
group: root
mode: 0444
notify:
- call ldconfig

0 comments on commit 28e94f9

Please sign in to comment.