[playbook,solr] download, install, and run Solr on a ubuntu server

This commit is contained in:
bronsen 2025-03-03 23:20:24 +01:00
parent 61452e0cb9
commit 47d8488264
2 changed files with 55 additions and 0 deletions

6
playbooks/solr-vars.yaml Normal file
View file

@ -0,0 +1,6 @@
---
download_dir: /tmp
solr_dir: /opt/solr
solr_version: 8.6.0
solr_checksum: sha512:6b0d618069e37215f305d9a61a3e65be2b9cfc32a3689ea6a25be2f220b1ecc96a644ecc31c81e335a2dfa0bc8b7d0f2881ca192c36fd435cdd832fd309a9ddb

49
playbooks/solr.yaml Normal file
View file

@ -0,0 +1,49 @@
---
- name: Ubuntu server with Solr
hosts: ubu
become: true
vars_files:
- solr-vars.yaml
pre_tasks:
- name: Update apt cache if needed.
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
tasks:
- name: Install Java.
ansible.builtin.apt:
name: openjdk-11-jdk
state: present
- name: Get Solr.
ansible.builtin.get_url:
url: "https://archive.apache.org/dist/lucene/solr/{{ solr_version }}/solr-{{ solr_version }}.tgz"
dest: "{{ download_dir }}/solr-{{ solr_version }}.tgz"
checksum: "{{ solr_checksum }}"
- name: Expand Solr archive.
ansible.builtin.unarchive:
src: "{{ download_dir }}/solr-{{ solr_version }}.tgz"
dest: "{{ download_dir }}"
remote_src: true
creates: "{{ download_dir }}/solr-{{ solr_version }}/README.txt"
- name: Run Solr installation script.
ansible.builtin.command: >
{{ download_dir }}/solr-{{ solr_version }}/bin/install_solr_service.sh
{{ download_dir }}/solr-{{ solr_version }}.tgz
-i /opt
-d /var/solr
-u solr
-s solr
-p 8983
creates={{ solr_dir }}/bin/solr
- name: Ensure Solr is started and enabled on boot.
ansible.builtin.service:
name: solr
state: started
enabled: true