Add a systemd unit.
This commit is contained in:
parent
b4391a4064
commit
f9ec6f5267
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
# solr
|
# solr
|
||||||
solr_install: True
|
solr_install: True
|
||||||
solr_version: 7.4.0
|
solr_version: 9.7.0
|
||||||
solr_http_port: 8983
|
solr_http_port: 8983
|
||||||
solr_service: -solr
|
solr_service: -solr
|
||||||
solr_config_name: hindex
|
solr_config_name: hindex
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
---
|
---
|
||||||
- name: solr restart
|
- name: Solr restart
|
||||||
service: name=solr state=restarted
|
ansible.builtin.service:
|
||||||
|
name: solr
|
||||||
|
state: restarted
|
||||||
|
|
||||||
- name: Restart Solr prometheus exporter
|
- name: Restart Solr prometheus exporter
|
||||||
service: name=solr_prometheus_exporter state=restarted enabled=yes
|
ansible.builtin.service:
|
||||||
|
name: solr_prometheus_exporter
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Reload systemd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
---
|
---
|
||||||
- block:
|
- name: Manage the SOLR installation
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
when: solr_install
|
||||||
|
tags: solr
|
||||||
|
block:
|
||||||
- name: Create a solr user
|
- name: Create a solr user
|
||||||
user: name={{ solr_user }} home={{ solr_base_dir }} createhome=yes shell=/bin/bash system=yes
|
user: name={{ solr_user }} home={{ solr_base_dir }} createhome=yes shell=/bin/bash system=yes
|
||||||
|
|
||||||
|
@ -39,55 +44,63 @@
|
||||||
with_items:
|
with_items:
|
||||||
- solr.xml
|
- solr.xml
|
||||||
- zoo.cfg
|
- zoo.cfg
|
||||||
notify: solr restart
|
notify: Solr restart
|
||||||
tags: [ 'solr', 'solr_default', 'solr_conf' ]
|
tags: [ 'solr', 'solr_default', 'solr_conf' ]
|
||||||
|
|
||||||
- name: copy extra libraries
|
- name: copy extra libraries
|
||||||
shell: cd {{ solr_server_dir }}; cp -u {{ item }} {{ solr_data_dir }}/lib
|
shell: cd {{ solr_server_dir }}; cp -u {{ item }} {{ solr_data_dir }}/lib
|
||||||
with_items: '{{ solr_jar_files }}'
|
with_items: '{{ solr_jar_files }}'
|
||||||
|
|
||||||
- name: install the solr init script
|
|
||||||
template: src=solr dest=/etc/init.d/solr mode=0755 owner=root group=root
|
|
||||||
|
|
||||||
- name: Install the solr default
|
- name: Install the solr default
|
||||||
template: src=solr-default.j2 dest=/etc/default/solr.in.sh mode=0644 owner=root group=root
|
template: src=solr-default.j2 dest=/etc/default/solr.in.sh mode=0644 owner=root group=root
|
||||||
notify: solr restart
|
notify: Solr restart
|
||||||
tags: [ 'solr', 'solr_default', 'solr_conf' ]
|
tags: [ 'solr', 'solr_default', 'solr_conf' ]
|
||||||
|
|
||||||
|
- name: install the solr init script
|
||||||
|
template: src=solr dest=/etc/init.d/solr mode=0755 owner=root group=root
|
||||||
|
when: ansible_service_mgr != 'systemd'
|
||||||
|
|
||||||
|
- name: Install the SOLR systemd unit
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: solr.service.j2
|
||||||
|
dest: /etc/systemd/system/solr.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
tags: ['solr', 'solr_default', 'solr_conf', 'solr_init']
|
||||||
|
when: ansible_service_mgr == 'systemd'
|
||||||
|
notify: Reload systemd
|
||||||
|
- name: Reload the systemd service
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
- name: Start and enable the solr service
|
- name: Start and enable the solr service
|
||||||
service: name=solr state=started enabled=yes
|
service: name=solr state=started enabled=yes
|
||||||
ignore_errors: True
|
ignore_errors: true
|
||||||
|
|
||||||
become: True
|
- name: Manage the installation of the Solr metrics exporter
|
||||||
become_user: root
|
become: true
|
||||||
when: solr_install
|
|
||||||
tags: solr
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Create the Solr prometheus exporter conf directory
|
|
||||||
file: dest={{ solr_prometheus_conf_dir }} state=directory mode=0755
|
|
||||||
|
|
||||||
- name: Install the Solr prometheus exporter config file
|
|
||||||
template: src=solr-exporter-config.xml dest={{ solr_prometheus_conf_file }} mode=0644
|
|
||||||
notify: Restart Solr prometheus exporter
|
|
||||||
tags: [ 'solr', 'solr_prometheus', 'solr_prometheus_exporter', 'solr_prometheus_exporter_config' ]
|
|
||||||
|
|
||||||
- name: Install the Solr prometheus exporter upstart script
|
|
||||||
template: src=solr_prometheus_exporter.upstart.j2 dest=/etc/init/solr_prometheus_exporter.conf mode=0644 owner=root group=root
|
|
||||||
when: ansible_service_mgr != 'systemd'
|
|
||||||
|
|
||||||
- name: Install the Solr prometheus exporter systemd unit
|
|
||||||
template: src=solr_prometheus_exporter.systemd.j2 dest=/etc/systemd/system/solr_prometheus_exporter.service mode=0644 owner=root group=root
|
|
||||||
when: ansible_service_mgr == 'systemd'
|
|
||||||
notify: systemd reload
|
|
||||||
|
|
||||||
- name: Ensure that Solr prometheus exporter is started and enabled
|
|
||||||
service: name=solr_prometheus_exporter state=started enabled=yes
|
|
||||||
|
|
||||||
become: True
|
|
||||||
become_user: root
|
become_user: root
|
||||||
when:
|
when:
|
||||||
- solr_install
|
- solr_install
|
||||||
- solr_prometheus_exporter
|
- solr_prometheus_exporter
|
||||||
tags: [ 'solr', 'solr_prometheus', 'solr_prometheus_exporter' ]
|
tags: ['solr', 'solr_prometheus', 'solr_prometheus_exporter']
|
||||||
|
block:
|
||||||
|
- name: Create the Solr prometheus exporter conf directory
|
||||||
|
file: dest={{ solr_prometheus_conf_dir }} state=directory mode=0755
|
||||||
|
|
||||||
|
- name: Install the Solr prometheus exporter config file
|
||||||
|
template: src=solr-exporter-config.xml dest={{ solr_prometheus_conf_file }} mode=0644
|
||||||
|
notify: Restart Solr prometheus exporter
|
||||||
|
tags: [ 'solr', 'solr_prometheus', 'solr_prometheus_exporter', 'solr_prometheus_exporter_config' ]
|
||||||
|
|
||||||
|
- name: Install the Solr prometheus exporter upstart script
|
||||||
|
template: src=solr_prometheus_exporter.upstart.j2 dest=/etc/init/solr_prometheus_exporter.conf mode=0644 owner=root group=root
|
||||||
|
when: ansible_service_mgr != 'systemd'
|
||||||
|
|
||||||
|
- name: Install the Solr prometheus exporter systemd unit
|
||||||
|
template: src=solr_prometheus_exporter.systemd.j2 dest=/etc/systemd/system/solr_prometheus_exporter.service mode=0644 owner=root group=root
|
||||||
|
when: ansible_service_mgr == 'systemd'
|
||||||
|
notify: systemd reload
|
||||||
|
|
||||||
|
- name: Ensure that Solr prometheus exporter is started and enabled
|
||||||
|
service: name=solr_prometheus_exporter state=started enabled=yes
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Apache Solr
|
||||||
|
After=network.target
|
||||||
|
StartLimitIntervalSec=300
|
||||||
|
StartLimitBurst=5
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
User=solr
|
||||||
|
Environment=SOLR_INCLUDE=/etc/default/solr.in.sh
|
||||||
|
Environment=RUNAS=solr
|
||||||
|
ExecStart=${SOLR_INSTALL_DIR}/bin/solr start
|
||||||
|
ExecStop=${SOLR_INSTALL_DIR}/bin/solr stop
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=3s
|
||||||
|
TimeoutSec=180s
|
||||||
|
PrivateTmp=true
|
||||||
|
LimitNOFILE=65000
|
||||||
|
LimitNPROC=65000
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue