Control restarts via systemd

This commit is contained in:
phil 2023-12-06 10:46:59 +01:00
parent fd4b90f43d
commit ca60540f15
4 changed files with 19 additions and 20 deletions

View file

@ -0,0 +1,8 @@
# Ansible managed
[Unit]
StartLimitIntervalSec=6
StartLimitBurst=10
[Service]
Restart=on-failure

View file

@ -1,10 +1,7 @@
--- ---
- name: reload monit
ansible.builtin.service:
name: monit
state: reloaded
- name: restart opensearch - name: restart opensearch
ansible.builtin.service: ansible.builtin.systemd:
name: opensearch name: opensearch
daemon_reload: true
state: restarted state: restarted
enabled: true

View file

@ -39,6 +39,13 @@
replace: -Xmx{{ (ansible_memtotal_mb / 1024 * 0.5) | round | int }}g replace: -Xmx{{ (ansible_memtotal_mb / 1024 * 0.5) | round | int }}g
notify: restart opensearch notify: restart opensearch
- name: Copy systemd override
ansible.builtin.copy:
src: systemd/override.conf
dest: /etc/systemd/system/opensearch.service.d/
mode: "0644"
notify: restart opensearch
- name: "Opensearch | Start opensearch" - name: "Opensearch | Start opensearch"
ansible.builtin.systemd: ansible.builtin.systemd:
name: opensearch name: opensearch
@ -46,15 +53,9 @@
state: started state: started
daemon_reload: true daemon_reload: true
- name: "Opensearch | Enable Monit monitoring"
ansible.builtin.template:
src: opensearch.monit.j2
dest: /etc/monit/conf-enabled/opensearch
mode: "0644"
notify: reload monit
- name: "Opensearch | Copy update script" - name: "Opensearch | Copy update script"
ansible.builtin.template: ansible.builtin.template:
src: update-opensearch-plugins.j2 src: update-opensearch-plugins.j2
dest: "/usr/local/bin/{{ opensearch_plugin_update_script }}" dest: "/usr/local/bin/{{ opensearch_plugin_update_script }}"
mode: "0755" mode: "0755"

View file

@ -1,7 +0,0 @@
# {{ ansible_managed }}
check process {{ opensearch_monit_service }} with pidfile /run/opensearch/opensearch.pid
start program = "/usr/sbin/service opensearch start"
stop program = "/usr/sbin/service opensearch stop"
if failed host {{ opensearch_network_host }} port {{ opensearch_http_port }} for 3 cycles then restart
if 5 restarts within 5 cycles then timeout