geerlingguy.solr
Ansible Role: Apache Solr
This Ansible role installs Apache Solr on Linux servers.
Requirements
Java needs to be installed on the server. You can use the geerlingguy.java
role to install it easily. Make sure that the installed Java version meets Solr's minimum requirements (like Java 8 for Solr 6+).
This role works with Solr versions 3.x, 4.x, 5.x, 6.x, 7.x, and 8.x.
Role Variables
Here are the variables you can set, along with their default values (found in defaults/main.yml
):
solr_workspace:
/root
This is the path where files will be downloaded on the server before being moved to their final location.solr_create_user:
true
solr_user:solr
solr_group:{{ solr_user }}
Solr will run under thesolr_user
. If the user already exists or you're using Solr 5+ and want its installer to handle the user creation, setsolr_create_user
tofalse
. By default,solr_group
is the same assolr_user
, but you can change its value if needed.solr_version:
"8.11.2"
This is the version of Apache Solr that will be installed. Check available Apache Solr versions for a complete list.solr_mirror:
"https://archive.apache.org/dist"
This is the mirror site from which the Solr files will be downloaded. If you experience slow downloads, you can point it to a different mirror suggested by Apache's mirror download site.solr_remove_cruft:
false
This option decides whether to remove unnecessary documentation and examples from the Solr directory.solr_service_manage:
true
solr_service_name:solr
solr_service_state:started
By default, this role will manage thesolr
service, ensuring it starts with the system and runs. Setsolr_service_state: stopped
to stop Solr or setsolr_service_manage: false
if you don't want this role to manage the service. In that case, you might also want to setsolr_restart_handler_enabled: false
.solr_install_dir:
/opt
solr_install_path:/opt/solr
This is where Apache Solr will be installed. For Solr 5+, the installer will usesolr_install_dir
. For earlier versions, files will be copied tosolr_install_path
.solr_home:
/var/solr
This is the location for Solr data (like search collections and settings). It's best to keep this separate from the installation path for easier updates.solr_port:
"8983"
The port on which Solr will operate.solr_xms:
"256M"
solr_xmx:"512M"
These are memory settings for the JVM. It's good to set these as high as possible for better performance and to minimize Out Of Memory (OOM) issues.solr_timezone:
"UTC"
The default timezone for the JVM running Solr. This can be changed if necessary, especially when working with data imports.solr_opts:
"$SOLR_OPTS -Dlog4j2.formatMsgNoLookups=true"
These are options for Solr, included to help mitigate certain security issues.solr_cores:
collection1
A list of collections that should exist on the server. This variable is relevant if you're using Solr 5+.
solr_connect_host:
localhost
The hostname or IP where Solr will be accessible.localhost
works in many cases, but sometimes you might need to use a different address.solr_restart_handler_enabled:
true
This option determines if therestart solr
handler should be used. Disable it if you're creating containers or AMIs.
Variables for Solr < 5
These variables apply only to Solr 4 and earlier:
solr_log_file_path:
/var/log/solr.log
This is where the Solr log file will go.solr_host:
"0.0.0.0"
This is the address Solr will bind to. The default allows Solr to listen on all network interfaces.
Dependencies
There are no dependencies.
Example Playbook
- hosts: solr-servers
roles:
- geerlingguy.java
- geerlingguy.solr
License
MIT / BSD
Author Information
This role was created in 2014 by Jeff Geerling, the author of Ansible for DevOps.
Apache Solr for Linux.
ansible-galaxy install geerlingguy.solr