Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Update Solr role to latest version to fix core issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Apr 4, 2017
1 parent 6620b42 commit 866c1db
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 50 deletions.
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@
- src: geerlingguy.security
version: 1.5.0
- src: geerlingguy.solr
version: 3.5.2
version: 3.5.3
- src: geerlingguy.varnish
version: 1.8.4
2 changes: 2 additions & 0 deletions provisioning/roles/geerlingguy.solr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.retry
tests/test.sh
61 changes: 16 additions & 45 deletions provisioning/roles/geerlingguy.solr/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,37 @@ services: docker
env:
# Test current version of Solr on latest supported OSes.
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
solr_major_version: 6
playbook: test-solr-6.yml
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
solr_major_version: 6
playbook: test-solr-6.yml
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
solr_major_version: 6
playbook: test-solr-6.yml

# Test older versions of Solr / OSes.
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
solr_major_version: 5
playbook: test-solr-5.yml
- distro: ubuntu1204
init: /sbin/init
run_opts: ""
solr_major_version: 5
playbook: test-solr-5.yml
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
solr_major_version: 4
playbook: test-solr-4.yml
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
solr_major_version: 3

before_install:
# Pull container.
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
playbook: test-solr-3.yml

script:
- container_id=$(mktemp)
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'

# Install dependencies.
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false

# Ansible syntax check.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-solr-${solr_major_version}.yml --syntax-check'
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh

# Test role.
- 'docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-solr-${solr_major_version}.yml'

# Test role idempotence.
- idempotence=$(mktemp)
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-solr-${solr_major_version}.yml | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Run tests.
- ${PWD}/tests/test.sh

# Make sure Solr is running.
- >
sudo docker exec "$(cat ${container_id})" ps -ax | grep -q 'solr'
sudo docker exec ${container_id} ps -ax | grep -q 'solr'
&& (echo 'solr is running: pass' && exit 0)
|| (echo 'solr is running: fail' && exit 1)
Expand Down
20 changes: 20 additions & 0 deletions provisioning/roles/geerlingguy.solr/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2017 Jeff Geerling

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.
4 changes: 4 additions & 0 deletions provisioning/roles/geerlingguy.solr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Default timezone of JVM running solr. You can override this if needed when using

A list of cores / collections which should exist on the server. Each one will be created (if it doesn't exist already) using the default example configuration that ships with Solr. Note that this variable only applies when using Solr 5+.

solr_connect_host: localhost

The hostname or IP address on which Solr will be reachable. `localhost` should work in most circumstances, but there are special cases where you may only be able to access the local Solr instance via another IP or hostname.

### Variables used only for Solr < 5.

The following variables are currently only applied to installations of Solr 4 and below:
Expand Down
1 change: 1 addition & 0 deletions provisioning/roles/geerlingguy.solr/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ solr_service_name: solr
solr_install_dir: /opt
solr_install_path: "/opt/{{ solr_service_name }}"
solr_home: /var/solr
solr_connect_host: localhost
solr_port: "8983"

solr_xms: "256M"
Expand Down
8 changes: 4 additions & 4 deletions provisioning/roles/geerlingguy.solr/tasks/cores.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Check current list of Solr cores.
uri:
url: http://localhost:{{ solr_port }}/solr/admin/cores
url: http://{{ solr_connect_host }}:{{ solr_port }}/solr/admin/cores
return_content: yes
register: solr_cores_current

Expand All @@ -12,19 +12,19 @@
owner: "{{ solr_user }}"
group: "{{ solr_user }}"
recurse: yes
when: "'{{ item }}' not in '{{ solr_cores_current.content }}'"
when: "item not in solr_cores_current.content"
with_items: "{{ solr_cores }}"

- name: Ensure core configuration directories exist.
shell: "cp -r {{ solr_install_path }}/example/files/conf/ {{ solr_home }}/data/{{ item }}/"
when: "'{{ item }}' not in '{{ solr_cores_current.content }}'"
when: "item not in solr_cores_current.content"
with_items: "{{ solr_cores }}"
become: yes
become_user: "{{ solr_user }}"

- name: Create configured cores.
shell: "{{ solr_install_path }}/bin/solr create -c {{ item }}"
when: "'{{ item }}' not in '{{ solr_cores_current.content }}'"
when: "item not in solr_cores_current.content"
with_items: "{{ solr_cores }}"
become: yes
become_user: "{{ solr_user }}"
11 changes: 11 additions & 0 deletions provisioning/roles/geerlingguy.solr/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ansible Role tests

To run the test playbook(s) in this directory:

1. Install and start Docker.
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
1. Make the test shim executable: `chmod +x tests/test.sh`.
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`

If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`

1 comment on commit 866c1db

@suresh-kumara-gist
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @geerlingguy I had same issue this commit fix my issue.

Please sign in to comment.