-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #8: Complete rewrite for modern Solr installation.
- Loading branch information
1 parent
68e1f56
commit bfcfb80
Showing
17 changed files
with
315 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
--- | ||
workspace: /root | ||
tomcat_user: tomcat | ||
tomcat_lib_path: /usr/share/tomcat6/lib/ | ||
solr_version: "4.10.2" | ||
solr_path: /opt/solr | ||
|
||
# The first core in the list will be set as the default Solr core. For now, this | ||
# list is hardcoded here and shouldn't be overridden unless you know what you're | ||
# doing. Someday, this will be more easily configurable. | ||
solr_cores: | ||
- core0 | ||
- core1 | ||
solr_workspace: /root | ||
|
||
solr_create_user: true | ||
solr_user: solr | ||
|
||
solr_version: "4.10.4" | ||
|
||
solr_install_path: /opt/solr | ||
solr_home: /var/solr | ||
solr_log_file_path: /var/log/solr.log | ||
|
||
solr_port: "8983" | ||
solr_xms: "256M" | ||
solr_xmx: "512M" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: restart solr | ||
service: name=solr state=restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: Ensure log file is created and has proper permissions. | ||
file: | ||
path: "/var/log/solr.log" | ||
state: touch | ||
owner: "{{ solr_user }}" | ||
group: root | ||
mode: 0664 | ||
changed_when: false | ||
|
||
- name: Copy solr init script into place. | ||
template: | ||
src: "solr-init-{{ ansible_os_family }}.j2" | ||
dest: /etc/init.d/solr | ||
mode: 0755 | ||
notify: restart solr | ||
|
||
- name: Ensure daemon is installed (Debian). | ||
apt: name=daemon state=installed | ||
when: ansible_os_family == "Debian" | ||
|
||
- name: Ensure solr is started and enabled on boot. | ||
service: name=solr state=started enabled=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,39 @@ | ||
--- | ||
- name: Include OS-specific variables. | ||
include_vars: "{{ ansible_os_family }}.yml" | ||
- include: user.yml | ||
when: solr_create_user | ||
|
||
- name: Set solr_filename for Solr 4.x. | ||
set_fact: > | ||
solr_filename=solr-{{ solr_version }} | ||
set_fact: | ||
"solr_filename=solr-{{ solr_version }}" | ||
when: "solr_version.split('.')[0] == '4'" | ||
|
||
- name: Set solr_filename for Solr 3.x. | ||
set_fact: > | ||
solr_filename=apache-solr-{{ solr_version }} | ||
set_fact: | ||
solr_filename: "apache-solr-{{ solr_version }}" | ||
when: "solr_version.split('.')[0] == '3'" | ||
|
||
- name: Download Solr. | ||
get_url: > | ||
url=http://archive.apache.org/dist/lucene/solr/{{ solr_version }}/{{ solr_filename }}.tgz | ||
dest={{ workspace }}/{{ solr_filename }}.tgz | ||
force=no | ||
get_url: | ||
url: "http://archive.apache.org/dist/lucene/solr/{{ solr_version }}/{{ solr_filename }}.tgz" | ||
dest: "{{ solr_workspace }}/{{ solr_filename }}.tgz" | ||
force: no | ||
|
||
- name: Expand Solr. | ||
command: > | ||
tar -C {{ workspace }} -xvzf {{ workspace }}/{{ solr_filename }}.tgz | ||
creates={{ workspace }}/{{ solr_filename }}/dist/{{ solr_filename }}.war | ||
tar -C {{ solr_workspace }} -xvzf {{ solr_workspace }}/{{ solr_filename }}.tgz | ||
creates={{ solr_workspace }}/{{ solr_filename }}/dist/{{ solr_filename }}.war | ||
- name: Copy Solr into place. | ||
command: > | ||
cp -r {{ workspace }}/{{ solr_filename }} {{ solr_path }} | ||
creates={{ solr_path }}/dist/{{ solr_filename }}.war | ||
- name: Copy Solr war file into place. | ||
command: > | ||
cp {{ solr_path }}/dist/{{ solr_filename }}.war {{ solr_path }}/solr.war | ||
creates={{ solr_path }}/solr.war | ||
notify: restart tomcat | ||
|
||
- name: Copy solr.xml into Tomcat. | ||
template: > | ||
src=Catalina/solr.xml.j2 | ||
dest=/etc/tomcat6/Catalina/{{ tomcat6_hostname }}/solr.xml | ||
owner={{ tomcat_user }} group={{ tomcat_user }} mode=755 | ||
notify: restart tomcat | ||
|
||
- name: Copy Solr multicore example into place. | ||
command: > | ||
cp -R {{ solr_path }}/example/multicore {{ solr_path }}/cores | ||
creates={{ solr_path }}/cores/README.txt | ||
notify: restart tomcat | ||
|
||
- name: Check if solr.xml file already exists. | ||
stat: "path={{ solr_path }}/solr.xml" | ||
register: solr_file | ||
|
||
- name: Copy Solr core XML file into place. | ||
template: > | ||
src=solr.xml.j2 | ||
dest={{ solr_path }}/solr.xml | ||
owner={{ tomcat_user }} | ||
group={{ tomcat_user }} | ||
mode=755 | ||
backup=yes | ||
when: solr_file.stat.exists == false | ||
notify: restart tomcat | ||
|
||
- name: Check if setup-complete file exists. | ||
stat: "path={{ solr_path }}/setup-complete" | ||
register: setup_complete | ||
|
||
- name: Copy logging jar files and configuration into place for Solr 4.x. | ||
shell: "{{ item }}" | ||
with_items: | ||
- "cp -n {{ solr_path }}/example/lib/ext/* {{ tomcat_lib_path }}" | ||
- "cp -n {{ solr_path }}/example/resources/log4j.properties {{ tomcat_lib_path }}" | ||
when: "(setup_complete.stat.exists == false) and (solr_version.split('.')[0] == '4')" | ||
notify: restart tomcat | ||
|
||
- name: Fix file permissions. | ||
file: > | ||
path={{ solr_path }} | ||
state=directory | ||
owner={{ tomcat_user }} group={{ tomcat_user }} mode=0755 | ||
recurse=yes | ||
when: setup_complete.stat.exists == false | ||
|
||
- name: Create file to indicate Solr install completion. | ||
file: > | ||
path={{ solr_path }}/setup-complete | ||
state=touch | ||
owner={{ tomcat_user }} | ||
group={{ tomcat_user }} | ||
mode=755 | ||
when: setup_complete.stat.exists == false | ||
cp -r {{ solr_workspace }}/{{ solr_filename }} {{ solr_install_path }} | ||
creates={{ solr_install_path }}/dist/{{ solr_filename }}.war | ||
- name: Ensure Solr install files are owned by the solr_user. | ||
file: | ||
path: "{{ solr_install_path }}" | ||
owner: "{{ solr_user }}" | ||
group: "{{ solr_user }}" | ||
recurse: yes | ||
|
||
- include: solr-home.yml | ||
- include: init.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Ensure solr_home directory exists. | ||
file: | ||
path: "{{ solr_home }}" | ||
state: directory | ||
owner: "{{ solr_user }}" | ||
group: "{{ solr_user }}" | ||
mode: 0755 | ||
|
||
- name: Check if solr_home is already set up. | ||
stat: "path={{ solr_home }}/solr.xml" | ||
register: solr_example | ||
|
||
- name: Copy Solr example into solr_home. | ||
shell: "cp -r {{ solr_install_path }}/example/solr/* {{ solr_home }}" | ||
when: not solr_example.stat.exists | ||
|
||
- name: Fix the example solrconfig.xml file. | ||
replace: | ||
dest: "{{ solr_home }}/collection1/conf/solrconfig.xml" | ||
regexp: ^.+solr\.install\.dir.+$ | ||
replace: "" | ||
when: "not solr_example.stat.exists and solr_version.split('.')[0] == '3'" | ||
|
||
- name: Ensure Solr home files are owned by the solr_user. | ||
file: | ||
path: "{{ solr_home }}" | ||
owner: "{{ solr_user }}" | ||
group: "{{ solr_user }}" | ||
recurse: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Ensure solr_user group exists. | ||
group: "name={{ solr_user }} state=present" | ||
|
||
- name: Ensure solr_user exists. | ||
user: | ||
name: "{{ solr_user }}" | ||
state: present | ||
group: "{{ solr_user }}" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.