diff --git a/.ansible-lint b/.ansible-lint index 35bb270..552a326 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,11 +1,28 @@ --- skip_list: - - 'risky-shell-pipe' - - 'role-name' - - 'name[template]' + - meta-no-info + - var-naming[no-role-prefix] + - name[template] warn_list: - package-latest - unnamed-task - - command-instead-of-shell - - no-handler + +exclude_paths: + - group_vars/secrets.* + - roles/dehydrated + - roles/mailhog + - roles/postgresql + - roles/mail + - roles/mariadb + - roles/nginx + - roles/elasticsearch + - roles/oauth2_proxy + - roles/php + - roles/redis + - roles/supervisord + - roles/system + - roles/apache + - roles/solr + - roles/varnish + - roles/docker diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f202fbd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# 2 space indentation for YAML +[{*.yml,*.yaml}] +indent_style = space +indent_size = 2 diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..455c5ee --- /dev/null +++ b/.envrc @@ -0,0 +1,24 @@ +#!/bin/sh +if [ -n "$$DIRENV_DIFF" ]; then + # Do not `set -e` unless we're being run from direnv + set -e +fi + +if [ ! -f .venv/bin/activate ] +then + echo "Creating a virtual Python environment" + python3 -m venv .venv >/dev/null +fi + +if [ -f .venv/bin/activate ] +then + echo "Activating the Python virtual environment" + . .venv/bin/activate +fi + +if [ -f .venv/bin/pip3 ] +then + echo "Installing Python requirements" + .venv/bin/pip3 install --upgrade pip 1> /dev/null + .venv/bin/pip3 install -r requirements.txt 1> /dev/null +fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83c6a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.DS_Store +*.pyc +__pycache__ +.idea +.vscode +/*.retry +/.fact_cache +/venv/ +debug.log +id_ed25519* +/venv*/ +.collections +roles +.venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53611d0..2830351 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,7 @@ --- repos: - repo: https://github.com/ansible/ansible-lint.git - rev: v6.17.2 + rev: v24.6.1 hooks: - id: ansible-lint + files: \.(yaml|yml)$ diff --git a/.yamllint b/.yamllint index 8827676..2ac072a 100644 --- a/.yamllint +++ b/.yamllint @@ -1,33 +1,15 @@ --- -# Based on ansible-lint config extends: default rules: + line-length: disable + truthy: + allowed-values: ['true', 'false', 'yes', 'no'] + comments: + min-spaces-from-content: 1 braces: + min-spaces-inside: 0 max-spaces-inside: 1 - level: error - brackets: - max-spaces-inside: 1 - level: error - colons: - max-spaces-after: -1 - level: error - commas: - max-spaces-after: -1 - level: error - comments: disable - comments-indentation: disable - document-start: disable - empty-lines: - max: 3 - level: error - hyphens: - level: error - indentation: disable - key-duplicates: enable - line-length: disable - new-line-at-end-of-file: disable - new-lines: - type: unix - trailing-spaces: disable - truthy: disable + +ignore: | + .cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5609724 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 punkt.de GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0512c3d..f761d9a 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,104 @@ An Ansible role that sets up Apache Solr and Apache Tika on a Proserver Downloads the defined versions of Solr and Tika from [archive.apache.org](https://archive.apache.org) and enables their respective services. -### Example configuration +## Dependencies +* [ansible-proserver-oauth2-proxy](https://github.com/punktDe/ansible-proserver-oauth2-proxy) +* [ansible-proserver-nginx](https://github.com/punktDe/ansible-proserver-nginx) or [ansible-proserver-apache](https://github.com/punktDe/ansible-proserver-apache) +* [ansible-proserver-dehydrated](https://github.com/punktDe/ansible-proserver-dehydrated) +* [ansible-proserver-supervisord](https://github.com/punktDe/ansible-proserver-supervisord) + +## Background + +This role deactivates the built-in FreeBSD rc.d services for Solr and Tika and does not interfere with their respective working directories (/var/solr, /var/solr/db, etc.). + +Instead, it uses [supervisord](https://github.com/punktDe/ansible-proserver-supervisord) for service management, and works with the following folders: + +|Directory|Description| +|---|---| +|/var/opt/solr/solr|Solr working directory| +|/var/opt/solr/home|Solr home| +|/var/opt/solr/tika|Tika working directory| +|/var/log/solr-ansible|Solr and Tika Logs| + +## Configuration The default configuration values can be found in defaults/main.yaml +### solr.url +**Default**: empty + +The URL for the Solr WebUI +```yaml +solr: + url: https://solr.example.com +``` + +### solr.oauth2_proxy +**Default**: empty + +The oauth2_proxy configuration that should be used for Solr WebUI authentiacation. + +Should be defined under `oauth2_proxy.$configuration` e.g. `oauth2_proxy.main` or `oauth2_proxy.solr` + +If empty, the WebUI will be publicly available, with no authentication. +```yaml +solr: + oauth2_proxy: main +``` + +### solr.overwrite_home +**Default**: no + +If enabled, will erase the Solr home directory (default: /var/opt/solr/home) on version change. + +**Use with caution** – this will also remove all your cores and custom configurations for them. + +```yaml +solr: + overwrite_home: yes +``` + +If disabled, it will still handle the `solr.xml` as followed: + +In case `solr.version` is **older than 9.x**, it will comment out the following parameters in your `solr.xml`: + +* allowUrls +* modules +* zkCredentialsInjector +* distributedClusterStateUpdates +* distributedCollectionConfigSetExecution +* minStateByteLenForCompression +* stateCompressor +* hideStackTrace + +These configuration parameters are present in the default `solr.xml` file shipped with 9.x, but are incompatible with versions 8.x and older. + +The commented out lines are marked with the text `disabled by Ansible`. + +In case `solr.version` is 9.x or newer, the role will uncomment all config lines that contain the text `disabled by Ansible`. + +### solr.prefix +The directories for Solr and Tika ```yaml solr: - domain: https://solr.example.com prefix: - bin: /var/solr - var: /var/db/solr - version: 9.2.0 + bin: /var/opt/solr/solr + home: /var/opt/solr/home + tika: /var/opt/solr/tika + logs: /var/log/solr-ansible +``` + +### solr.version +Solr version to install. Make sure the version exists on either https://archive.apache.org/dist/lucene/solr/ (pre 9.x) or https://archive.apache.org/dist/solr/solr/ (9.x) +```yaml +solr: + version: 9.7.0 +``` + +### solr.tika.version +Tika version to install. Make sure the version exists on https://archive.apache.org/dist/tika +```yaml +solr: tika: - prefix: - bin: /var/opt/tika - version: 2.8.0 - synced_config: /path/to/synced/config - oauth2_proxy: main # https://github.com/punktDe/ansible-proserver-oauth2-proxy + version: 3.0.0 ``` diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..fac200a --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +roles_path = ./roles +collections_path = ./.collections + +[ssh_connection] +pipelining = true diff --git a/defaults/main.yaml b/defaults/main.yaml index b1570da..a4f020c 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -1,13 +1,13 @@ --- solr: - domain: + url: prefix: - bin: /var/solr - var: /var/db/solr - version: 9.2.0 + bin: /var/opt/solr/solr + home: /var/opt/solr/home + tika: /var/opt/solr/tika + logs: /var/log/solr-ansible + version: 9.7.0 tika: - prefix: - bin: /var/opt/tika - version: 2.8.0 - synced_config: + version: 3.0.0 oauth2_proxy: + overwrite_home: no diff --git a/handlers/main.yaml b/handlers/main.yaml index 2f51df0..9997776 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -1,14 +1,20 @@ --- - name: Start Solr - ansible.builtin.service: - name: solr - state: started + changed_when: yes + ansible.builtin.shell: + cmd: | + set -e -u -o pipefail + supervisorctl update solr + supervisorctl start solr register: solr_service_result - name: Restart Solr - ansible.builtin.service: - name: solr - state: restarted + changed_when: yes + ansible.builtin.shell: + cmd: | + set -e -u -o pipefail + supervisorctl update solr + supervisorctl restart solr when: not (solr_service_result is defined and solr_service_result.changed) - name: Start Tika diff --git a/meta/main.yaml b/meta/main.yaml index 304f52c..edc857d 100644 --- a/meta/main.yaml +++ b/meta/main.yaml @@ -1,10 +1,24 @@ --- +galaxy_info: + author: "Punkt.de" + license: "" + description: "Ansible role for Solr" + role_name: "proserver_solr" + namespace: "punktde" + min_ansible_version: "2.15" + dependencies: - role: dehydrated - role: nginx - when: inventory_hostname in groups.nginx or not inventory_hostname in groups.apache + when: + - groups.nginx is defined + - (inventory_hostname in groups.nginx or not inventory_hostname in groups.apache) - role: apache - when: inventory_hostname in groups.apache + when: + - groups.apache is defined + - inventory_hostname in groups.apache - role: oauth2_proxy - when: solr.oauth2_proxy is defined and solr.oauth2_proxy + when: + - solr.oauth2_proxy is defined + - solr.oauth2_proxy - role: supervisord diff --git a/molecule/.molecule.yml.tmp b/molecule/.molecule.yml.tmp new file mode 100644 index 0000000..c549054 --- /dev/null +++ b/molecule/.molecule.yml.tmp @@ -0,0 +1,27 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: geerlingguy/docker-ubuntu2204-ansible + command: /lib/systemd/systemd + pre_build_image: true + privileged: true + cgroupns_mode: host + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw +provisioner: + name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} +verifier: + name: ansible +scenario: + name: default + test_sequence: + - destroy + - create + - converge + - verify diff --git a/molecule/.verify.yml.tmp b/molecule/.verify.yml.tmp new file mode 100644 index 0000000..70761cd --- /dev/null +++ b/molecule/.verify.yml.tmp @@ -0,0 +1,8 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/molecule/converge.yml b/molecule/converge.yml new file mode 100644 index 0000000..b67fd71 --- /dev/null +++ b/molecule/converge.yml @@ -0,0 +1,9 @@ +--- +- name: Converge + hosts: all + environment: + GITHUB_ACTIONS: "maybe" + tasks: + - name: "Include {{ role_name }}" + ansible.builtin.include_role: + name: "{{ role_name }}" diff --git a/molecule/converge.yml.template b/molecule/converge.yml.template new file mode 100644 index 0000000..b233329 --- /dev/null +++ b/molecule/converge.yml.template @@ -0,0 +1,18 @@ +--- +- name: Converge + hosts: all + environment: + GITHUB_ACTIONS: "maybe" + tasks: + - name: "Include {{ role_name }}" + ansible.builtin.include_role: + name: "{{ role_name }}" +--- +- name: Converge + hosts: all + environment: + GITHUB_ACTIONS: "maybe" + tasks: + - name: "Include {{ role_name }}" + ansible.builtin.include_role: + name: "{{ role_name }}" diff --git a/molecule/molecule.yml b/molecule/molecule.yml new file mode 100644 index 0000000..c549054 --- /dev/null +++ b/molecule/molecule.yml @@ -0,0 +1,27 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: geerlingguy/docker-ubuntu2204-ansible + command: /lib/systemd/systemd + pre_build_image: true + privileged: true + cgroupns_mode: host + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw +provisioner: + name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} +verifier: + name: ansible +scenario: + name: default + test_sequence: + - destroy + - create + - converge + - verify diff --git a/molecule/verify.yml b/molecule/verify.yml new file mode 100644 index 0000000..70761cd --- /dev/null +++ b/molecule/verify.yml @@ -0,0 +1,8 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1042bff --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +ansible +ansible-lint +docker +molecule +molecule-plugins +yamllint +requests diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..b24b298 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,8 @@ +--- +collections: + - name: https://github.com/ansible-collections/community.general + type: git + - name: https://github.com/ansible-collections/community.crypto + type: git + - name: https://github.com/ansible-collections/ansible.posix + type: git diff --git a/tasks/apache.yaml b/tasks/apache.yaml index 80d4e8d..bd1bd5d 100644 --- a/tasks/apache.yaml +++ b/tasks/apache.yaml @@ -4,7 +4,6 @@ src: "{{ item }}" dest: "{{ render_path }}" owner: "root" - group: "{{ root_group }}" mode: "0644" loop_control: label: "{{ render_path }}" diff --git a/tasks/config.yaml b/tasks/config.yaml new file mode 100644 index 0000000..3121a8f --- /dev/null +++ b/tasks/config.yaml @@ -0,0 +1,47 @@ +--- +- name: Check if Solr home is already set up + register: solr_home + ansible.builtin.stat: + path: "{{ solr.prefix.home }}/solr.xml" + +- name: Install the example home files + when: not solr_home.stat.exists or solr.overwrite_home + ansible.posix.synchronize: + src: "{{ solr.prefix.bin }}/server/solr/" + dest: "{{ solr.prefix.home }}/" + delete: true + recursive: true + rsync_opts: + - --chown=solr:solr + - --no-times + - --checksum + use_ssh_args: yes + notify: Restart Solr + delegate_to: "{{ inventory_hostname }}" + +- name: Comment out unsupported options (Solr 8.x) + notify: Restart Solr + when: solr.version is ansible.builtin.version('9', '<') + loop: + - allowUrls + - modules + - zkCredentialsInjector + - distributedClusterStateUpdates + - distributedCollectionConfigSetExecution + - minStateByteLenForCompression + - stateCompressor + - hideStackTrace + ansible.builtin.lineinfile: + path: "{{ solr.prefix.home }}/solr.xml" + regexp: '^(?!<\!\-\-)(.*{{ item }}.*)$' + line: + state: present + backrefs: yes + +- name: Restore unsupported options (Solr 9.x) + notify: Restart Solr + when: solr.version is ansible.builtin.version('9', '>=') + ansible.builtin.replace: + path: "{{ solr.prefix.home }}/solr.xml" + regexp: "^.*$" + replace: \g<1> diff --git a/tasks/main.yaml b/tasks/main.yaml index a160c28..8facb34 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -2,6 +2,9 @@ - name: Install Apache Solr ansible.builtin.include_tasks: solr.yaml +- name: Configure Apache Solr + ansible.builtin.include_tasks: config.yaml + - name: Install Apache Tika ansible.builtin.include_tasks: tika.yaml diff --git a/tasks/nginx.yaml b/tasks/nginx.yaml index 9e62f44..5b6ea0f 100644 --- a/tasks/nginx.yaml +++ b/tasks/nginx.yaml @@ -4,7 +4,6 @@ src: "{{ item }}" dest: "{{ render_path }}" owner: "root" - group: "{{ root_group }}" mode: "0644" loop_control: label: "{{ render_path }}" diff --git a/tasks/solr.yaml b/tasks/solr.yaml index 2900545..7fdd1a4 100644 --- a/tasks/solr.yaml +++ b/tasks/solr.yaml @@ -1,13 +1,22 @@ --- -- name: Create program directory for Solr +- name: Create program directories for Solr ansible.builtin.file: path: "{{ item }}" state: directory owner: solr group: solr mode: "0755" - with_items: + recurse: yes + loop: - "{{ solr.prefix.bin }}" + - "{{ solr.prefix.home }}" + +- name: Create log directory for Solr + ansible.builtin.file: + path: "{{ solr.prefix.logs }}" + state: directory + owner: solr + mode: "0755" - name: Download Solr {{ solr.version }} ansible.builtin.get_url: @@ -19,37 +28,30 @@ mode: "0644" vars: solr_path_segment: "{{ 'solr' if solr.version[0] is ansible.builtin.version('9', '>=') else 'lucene' }}" - checksum_version: "{{ 'sha512' if solr.version[0] is ansible.builtin.version('9', '>=') else 'sha1' }}" + checksum_version: "sha512" register: solr_get_url_result -- name: Ignore unrecognized JVM options (for versions older than 9) - notify: Restart Solr - when: solr.version[0] is ansible.builtin.version('9', '<') - ansible.builtin.template: - dest: "/etc/rc.d/solr" - src: "rc.d/solr" - owner: root - mode: "0755" - -- name: Don't ignore unrecognized JVM options (for versions newer than 9) - notify: Restart Solr - when: solr.version[0] is ansible.builtin.version('9', '>=') - ansible.builtin.file: - path: "/etc/rc.d/solr" - state: absent - - name: Check if {{ solr.prefix.bin }}/bin exists register: solr_bin_exists ansible.builtin.stat: path: "{{ solr.prefix.bin }}/bin" +- name: Check the current Solr version + changed_when: no + when: solr_bin_exists + register: solr_current_version + ansible.builtin.command: + cmd: "{{ solr.prefix.bin }}/bin/solr version" + - name: Handle Solr update - when: solr_get_url_result.changed + when: not solr_bin_exists.stat.exists or solr.version not in solr_current_version.stdout block: - name: Stop Solr service - ansible.builtin.service: - name: solr - state: stopped + changed_when: yes + ansible.builtin.shell: + cmd: | + set -e -u -o pipefail + sudo supervisorctl stop solr || true - name: Kill all solr processes changed_when: yes @@ -65,38 +67,44 @@ with_items: - "{{ solr.prefix.bin }}" -- name: Unarchive Solr - when: solr_get_url_result.changed or not solr_bin_exists.stat.exists - notify: Restart Solr - ignore_errors: "{{ ansible_check_mode }}" - ansible.builtin.unarchive: - src: "{{ solr.prefix.bin }}/solr-{{ solr.version }}.tar.gz" - owner: solr - group: solr - dest: "{{ item }}" - extra_opts: - - --strip-components=1 - remote_src: yes - with_items: - - "{{ solr.prefix.bin }}" - - -- name: Sync Solr config - ansible.posix.synchronize: - src: "{{ solr.synced_config }}/" - dest: "{{ item }}" - rsync_opts: - - --chown=solr:solr - - --no-times - - --checksum - use_ssh_args: yes - with_items: - - "{{ solr.prefix.var }}" - when: solr.synced_config - notify: Restart Solr + - name: Unarchive Solr + notify: Restart Solr + ignore_errors: "{{ ansible_check_mode }}" + ansible.builtin.unarchive: + src: "{{ solr.prefix.bin }}/solr-{{ solr.version }}.tar.gz" + owner: solr + group: solr + dest: "{{ item }}" + extra_opts: + - --strip-components=1 + remote_src: yes + with_items: + - "{{ solr.prefix.bin }}" -- name: Enable Solr service +- name: Stop and disable the native rc.d Solr service + failed_when: no ansible.builtin.service: name: solr - enabled: yes - notify: Start Solr + state: stopped + enabled: no + notify: + - Start Solr + - Restart Solr + +- name: Install Solr service + ansible.builtin.template: + src: supervisord.d/solr.conf + dest: "/usr/local/etc/supervisord.d/solr.conf" + owner: root + group: wheel + mode: "0755" + notify: + - Start Solr + - Restart Solr + +- name: Reload supervisord configuration + changed_when: no + ansible.builtin.shell: + cmd: | + set -e -u -o pipefail + sudo supervisorctl update diff --git a/tasks/tika.yaml b/tasks/tika.yaml index 6d1bb54..44e873d 100644 --- a/tasks/tika.yaml +++ b/tasks/tika.yaml @@ -4,30 +4,28 @@ path: "{{ item }}" state: directory owner: root - group: "{{ root_group }}" mode: "0755" with_items: - - "{{ solr.tika.prefix.bin }}" + - "{{ solr.prefix.tika }}" - name: Create log directory for Tika ansible.builtin.file: - path: "/var/log/tika" + path: "{{ solr.prefix.logs }}" state: directory - owner: nobody + owner: solr mode: "0755" - name: Download Tika {{ solr.tika.version }} register: tika_get_url_result ansible.builtin.get_url: url: "https://archive.apache.org/dist/tika/{{ solr.tika.version }}/tika-server-{{ tika_standard }}{{ solr.tika.version }}.jar" - dest: "{{ solr.tika.prefix.bin }}/tika-server.jar" + dest: "{{ solr.prefix.tika }}/tika-server.jar" checksum: "sha512:https://archive.apache.org/dist/tika/{{ solr.tika.version }}/tika-server-{{ tika_standard }}{{ solr.tika.version }}.jar.sha512" owner: root - group: "{{ root_group }}" mode: "0755" vars: tika_standard: "{{ 'standard-' if solr.tika.version is version('2', '>=') else '' }}" - notify: + notify: - Start Tika - Restart Tika @@ -37,7 +35,7 @@ name: tika state: stopped enabled: no - notify: + notify: - Start Tika - Restart Tika @@ -48,6 +46,13 @@ owner: root group: wheel mode: "0755" - notify: + notify: - Start Tika - Restart Tika + +- name: Reload supervisord configuration + changed_when: no + ansible.builtin.shell: + cmd: | + set -e -u -o pipefail + sudo supervisorctl update diff --git a/templates/rc.d/solr b/templates/rc.d/solr deleted file mode 100644 index d717571..0000000 --- a/templates/rc.d/solr +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# PROVIDE: solr -# REQUIRE: LOGIN -# KEYWORD: shutdown - -. /etc/rc.subr - -name=solr -rcvar=solr_enable -load_rc_config $name - -: ${solr_enable:=NO} -: ${solr_instance:=/var/db/solr} - -solr_start () -{ - su -m solr -c "${command} start -a '-XX:+IgnoreUnrecognizedVMOptions'" -} - -solr_stop () -{ - su -m solr -c "${command} stop" -} - -solr_status () -{ - su -m solr -c "${command} status" -} - -# add /usr/local/bin to path -export PATH=$PATH:/usr/local/bin - -required_files="${solr_instance}/solr.xml /usr/local/etc/solr.in.sh /usr/local/solr" -command=/usr/local/solr/bin/solr -start_cmd=solr_start -stop_cmd=solr_stop -status_cmd=solr_status - -run_rc_command "$1" diff --git a/templates/supervisord.d/solr.conf b/templates/supervisord.d/solr.conf new file mode 100644 index 0000000..a7c6c1a --- /dev/null +++ b/templates/supervisord.d/solr.conf @@ -0,0 +1,7 @@ +[program:solr] +user=solr +command={{ solr.prefix.bin }}/bin/solr start -f -s {{ solr.prefix.home }} +startsecs=10 +environment=PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin,SOLR_INCLUDE="{{ solr.prefix.bin }}/bin/solr.in.sh" +stdout_logfile={{ solr.prefix.logs }}/solr.log +redirect_stderr=true diff --git a/templates/supervisord.d/tika.conf b/templates/supervisord.d/tika.conf index 6455d16..240e9d7 100644 --- a/templates/supervisord.d/tika.conf +++ b/templates/supervisord.d/tika.conf @@ -1,7 +1,7 @@ [program:tika] -user=nobody +user=solr command=/usr/local/bin/java -Xmx1g -jar /var/opt/tika/tika-server.jar -h localhost -p 9998 startsecs=5 environment=PATH=/usr/local/bin:/usr/bin -stdout_logfile=/var/log/tika/tika.log +stdout_logfile={{ solr.prefix.logs }}/tika.log redirect_stderr=true