-
Notifications
You must be signed in to change notification settings - Fork 34
Use systemd for opendistro/kibana/filebeat #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9df8f62
use systemd for opendistro/kibana/filebeat
sjpb cb8a27f
move podman tmpdir onto /run to fix reboot issues
sjpb 3402090
remove incorrect podman group override in everything template
sjpb 2e7eecd
fix podman user tmp directory permissions
sjpb 81bb008
remove confirmation when resetting podman database
sjpb d7c0dcf
fix elasticsearch parameters in kibana unit file
sjpb 85a12de
remove hardcoded podman user/group name
sjpb 110cd34
Move podman temp dir code to podman role
sjpb 8b92166
remove hardcoded podman username in tmpfiles config
sjpb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
--- | ||
|
||
- name: Restart filebeat container | ||
command: podman restart filebeat | ||
systemd: | ||
name: filebeat.service | ||
state: restarted | ||
enabled: yes | ||
daemon_reload: yes | ||
become: true | ||
become_user: "{{ filebeat_podman_user }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
--- | ||
- name: Setup file beat | ||
containers.podman.podman_container: | ||
image: docker.elastic.co/beats/filebeat-oss:7.9.3 | ||
name: filebeat | ||
state: started | ||
user: root | ||
restart_policy: "always" | ||
security_opt: | ||
# Required to read /var/log. There might be a better solution, see:https://github.com/containers/podman/issues/3683 | ||
- label=disable | ||
volumes: | ||
- /var/log/:/logs:ro | ||
- /etc/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro | ||
command: -e -strict.perms=false -d "*" | ||
- name: Create systemd unit file | ||
template: | ||
dest: /etc/systemd/system/filebeat.service | ||
src: filebeat.service.j2 | ||
become: true | ||
become_user: "{{ filebeat_podman_user }}" | ||
notify: Restart filebeat container |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# container-filebeat.service | ||
# based off | ||
# podman generate systemd filebeat --restart-policy always --new --name | ||
# with pid/cidfiles replaced with --sdnotify=conmon approach | ||
|
||
[Unit] | ||
Description=Podman container-filebeat.service | ||
Documentation=man:podman-generate-systemd(1) | ||
Wants=network.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Environment=PODMAN_SYSTEMD_UNIT=%n | ||
Restart=always | ||
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --replace --name filebeat --user root --restart=always --security-opt label=disable --volume /var/log/:/logs:ro --volume /etc/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro --detach=True docker.elastic.co/beats/filebeat-oss:7.9.3 -e -strict.perms=false -d "*" | ||
ExecStop=/usr/bin/podman stop --ignore filebeat -t 10 | ||
ExecStopPost=/usr/bin/podman rm --ignore -f filebeat | ||
KillMode=none | ||
Type=notify | ||
NotifyAccess=all | ||
User={{ filebeat_podman_user }} | ||
Group={{ filebeat_podman_user }} | ||
TimeoutStartSec=180 | ||
|
||
[Install] | ||
WantedBy=multi-user.target default.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: Restart kibana container | ||
systemd: | ||
name: kibana.service | ||
state: restarted | ||
enabled: yes | ||
daemon_reload: yes | ||
become: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# container-kibana.service | ||
|
||
[Unit] | ||
Description=Podman container-kibana.service | ||
Documentation=man:podman-generate-systemd(1) | ||
Wants=network.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Environment=PODMAN_SYSTEMD_UNIT=%n | ||
Restart=always | ||
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon -d --replace --name kibana --restart=no --env ELASTICSEARCH_URL=https://{{ elasticsearch_address }}:9200 --env ELASTICSEARCH_HOSTS=https://{{ elasticsearch_address}}:9200 --env ELASTICSEARCH_USERNAME=admin --env ELASTICSEARCH_PASSWORD="{{ secrets_openhpc_elasticsearch_admin_password }}" --publish 5601:5601 --detach=True amazon/opendistro-for-elasticsearch-kibana:1.12.0 | ||
ExecStop=/usr/bin/podman stop --ignore kibana -t 10 | ||
ExecStopPost=/usr/bin/podman rm --ignore -f kibana | ||
KillMode=none | ||
Type=notify | ||
NotifyAccess=all | ||
User={{ kibana_podman_user }} | ||
Group={{ kibana_podman_user }} | ||
TimeoutStartSec=180 | ||
|
||
[Install] | ||
WantedBy=multi-user.target default.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
--- | ||
|
||
- name: Restart opendistro container | ||
command: podman restart opendistro | ||
systemd: | ||
name: opendistro.service | ||
state: restarted | ||
enabled: yes | ||
daemon_reload: yes | ||
become: true | ||
become_user: "{{ opendistro_podman_user }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# container-opendistro.service | ||
|
||
[Unit] | ||
Description=Podman container-opendistro.service | ||
Documentation=man:podman-generate-systemd(1) | ||
Wants=network.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Environment=PODMAN_SYSTEMD_UNIT=%n | ||
Restart=always | ||
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon -d --replace --name opendistro --restart=no --user elasticsearch --ulimit memlock=-1:-1 --ulimit nofile=65536:65536 --volume opendistro:/usr/share/elasticsearch/data --volume /etc/elastic/internal_users.yml:/usr/share/elasticsearch/plugins/opendistro_security/securityconfig/internal_users.yml:ro --env node.name=opendistro --env discovery.type=single-node --env bootstrap.memory_lock=true --env "ES_JAVA_OPTS=-Xms512m -Xmx512m" --publish 9200:9200 amazon/opendistro-for-elasticsearch:1.12.0 | ||
ExecStop=/usr/bin/podman stop --ignore opendistro -t 10 | ||
# note for some reason this returns status=143 which makes systemd show the unit as failed, not stopped | ||
ExecStopPost=/usr/bin/podman rm --ignore -f opendistro | ||
SuccessExitStatus=143 SIGTERM | ||
KillMode=none | ||
Type=notify | ||
NotifyAccess=all | ||
LimitNOFILE=65536 | ||
LimitMEMLOCK=infinity | ||
User={{ opendistro_podman_user }} | ||
Group={{ opendistro_podman_user }} | ||
TimeoutStartSec=180 | ||
|
||
[Install] | ||
WantedBy=multi-user.target default.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
podman_users: | ||
- name: "{{ ansible_user }}" | ||
podman_tmp_dir_root: /run # MUST be on a tmpfs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- name: Get tmp directory filesystem type | ||
command: stat -f -c %T {{ podman_tmp_dir_root }} | ||
register: podman_tmp_fstype | ||
changed_when: false | ||
|
||
- name: Check tmp directory is on tmpfs | ||
assert: | ||
that: podman_tmp_fstype.stdout == 'tmpfs' | ||
fail_msg: "{{ podman_tmp_fstype }} (variable podman_tmp_fstype) must be on tmpfs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
# Fail early if configuration is invalid | ||
|
||
- name: Validate podman configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put in podman role? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above as to why all of this isn't in the role. |
||
hosts: podman | ||
tags: podman | ||
tasks: | ||
- import_role: | ||
name: podman | ||
tasks_from: validate.yml | ||
tags: validate | ||
|
||
- name: Validate filebeat configuration | ||
hosts: filebeat | ||
tags: filebeat | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
podman_users: "{{ appliances_local_users_podman }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,6 @@ cluster | |
[mysql:children] | ||
control | ||
|
||
[podman:children] | ||
cluster | ||
|
||
[prometheus:children] | ||
control | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reckon we should only do this in one place and assume that the users exist in this role, but as this will essentially be a no-op at the cost of running a few extra tasks, probably not one to bike-shed over as the overall patch looks good to me.