Add all files needed to bring up VM and run agaric.com locally

This commit is contained in:
benjamin melançon 2018-08-20 10:45:20 -04:00
parent 52c8b60bac
commit 4d2bc0ee24
742 changed files with 24037 additions and 0 deletions

View file

@ -0,0 +1,2 @@
*.retry
tests/test.sh

View file

@ -0,0 +1,42 @@
---
services: docker
env:
# Test current version of Solr on latest supported OSes.
- distro: centos7
playbook: test-solr-6.yml
- distro: ubuntu1604
playbook: test-solr-6.yml
- distro: debian8
playbook: test-solr-6.yml
# Test older versions of Solr / OSes.
- distro: ubuntu1404
playbook: test-solr-5.yml
- distro: ubuntu1204
playbook: test-solr-5.yml
- distro: ubuntu1404
playbook: test-solr-4.yml
- distro: ubuntu1404
playbook: test-solr-3.yml
script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh
# Run tests.
- ${PWD}/tests/test.sh
# Make sure Solr is running.
- >
sudo docker exec ${container_id} ps -ax | grep -q 'solr'
&& (echo 'solr is running: pass' && exit 0)
|| (echo 'solr is running: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -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.

View file

@ -0,0 +1,98 @@
# Ansible Role: Apache Solr
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-solr.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-solr)
Installs [Apache Solr](http://lucene.apache.org/solr/) on Linux servers.
## Requirements
Java must be available on the server. You can easily install Java using the `geerlingguy.java` role. Make sure the Java version installed meets the minimum requirements of Solr (e.g. Java 8 for Solr 6+).
This role is currently tested and working with Solr 3.x, 4.x, 5.x and 6.x.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
solr_workspace: /root
Files will be downloaded to this path on the remote server before being moved into place.
solr_create_user: true
solr_user: solr
Solr will be run under the `solr_user`. Set `solr_create_user` to `false` if `solr_user` is created before this role runs, or if you're using Solr 5+ and want Solr's own installation script to set up the user.
solr_version: "6.2.0"
The Apache Solr version to install. For a full list, see [available Apache Solr versions](http://archive.apache.org/dist/lucene/solr/).
solr_mirror: "https://archive.apache.org/dist"
The Apache Project mirror from which the Solr tarball will be downloaded. In case of slow download speed or timeouts it is useful to set the mirror to the one suggested by Apache's [mirror download site](https://www.apache.org/dyn/closer.cgi/lucene/solr/).
solr_install_dir: /opt
solr_install_path: /opt/solr
The path where Apache Solr will be installed. For Solr 5+, the `solr_install_dir` will be used by Solr's installation script. For Solr < 5, the Solr installation files will be copied in place in the `solr_install_path`.
solr_home: /var/solr
The path where local Solr data (search collections and configuration) will be stored. Should typically be outside of the `solr_path`, to make Solr upgrades easier.
solr_port: "8983"
The port on which Solr will run.
solr_xms: "256M"
solr_xmx: "512M"
Memory settings for the JVM. These should be set as high as you can allow for best performance and to reduce the chance of Solr restarting itself due to OOM situations.
solr_timezone: "UTC"
Default timezone of JVM running solr. You can override this if needed when using dataimport and delta imports (ex: comparing against a MySQL external data source). Read through Apache Solr's [Working with Dates](https://cwiki.apache.org/confluence/display/solr/Working+with+Dates) documentation for more background.
solr_cores:
- collection1
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.
solr_restart_handler_enabled: true
Whether the `restart solr` handler should be used or not. If you're building containers or AMIs, you might need to disable the restart handler for a provisioning run.
### Variables used only for Solr < 5.
The following variables are currently only applied to installations of Solr 4 and below:
solr_log_file_path: /var/log/solr.log
Path where Solr log file will be created.
solr_host: "0.0.0.0"
The hostname or IP address to which Solr will bind. Defaults to `0.0.0.0` which allows Solr to listen on all interfaces.
## Dependencies
None.
## Example Playbook
- hosts: solr-servers
roles:
- geerlingguy.java
- geerlingguy.solr
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

View file

@ -0,0 +1,33 @@
---
solr_workspace: /root
solr_create_user: true
solr_user: solr
solr_version: "6.3.0"
solr_mirror: "https://archive.apache.org/dist"
solr_remove_cruft: false
solr_service_name: solr
solr_install_dir: /opt
solr_install_path: "/opt/{{ solr_service_name }}"
solr_home: "/var/{{ solr_service_name }}"
solr_connect_host: localhost
solr_port: "8983"
solr_xms: "256M"
solr_xmx: "512M"
solr_timezone: "UTC"
solr_cores:
- collection1
solr_config_file: /etc/default/{{ solr_service_name }}.in.sh
# Enable restart solr handler
solr_restart_handler_enabled: true
# Used only for Solr < 5.
solr_log_file_path: /var/log/solr.log
solr_host: "0.0.0.0"

View file

@ -0,0 +1,7 @@
---
- name: restart solr
service:
name: "{{ solr_service_name }}"
state: restarted
sleep: 5
when: solr_restart_handler_enabled

View file

@ -0,0 +1,22 @@
---
dependencies: []
galaxy_info:
author: geerlingguy
description: Apache Solr for Linux.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.2
platforms:
- name: EL
versions:
- 6
- 7
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags:
- development

View file

@ -0,0 +1,22 @@
---
- name: Remove existing SOLR_HEAP configuration.
lineinfile:
dest: "{{ solr_config_file }}"
regexp: "^SOLR_HEAP"
state: absent
notify: restart solr
- name: Apply Solr configuration changes.
lineinfile:
dest: "{{ solr_config_file }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
with_items:
- regexp: "^.?SOLR_JAVA_MEM="
line: 'SOLR_JAVA_MEM="-Xms{{ solr_xms }} -Xmx{{ solr_xmx }}"'
- regexp: "^SOLR_PORT="
line: 'SOLR_PORT="{{ solr_port }}"'
- regexp: "^.?SOLR_TIMEZONE="
line: 'SOLR_TIMEZONE="{{ solr_timezone }}"'
notify: restart solr

View file

@ -0,0 +1,30 @@
---
- name: Check current list of Solr cores.
uri:
url: http://{{ solr_connect_host }}:{{ solr_port }}/solr/admin/cores
return_content: yes
register: solr_cores_current
- name: Ensure Solr conf directories exist.
file:
path: "{{ solr_home }}/data/{{ item }}/conf"
state: directory
owner: "{{ solr_user }}"
group: "{{ solr_user }}"
recurse: yes
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"
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"
with_items: "{{ solr_cores }}"
become: yes
become_user: "{{ solr_user }}"

View file

@ -0,0 +1,83 @@
---
# Install Solr.
- name: Check if Solr is already installed.
stat: "path={{ solr_install_path }}/dist/{{ solr_filename }}.war"
register: solr_war_file
- name: Copy Solr into place.
command: "cp -r {{ solr_workspace }}/{{ solr_filename }} {{ solr_install_path }}"
when: not solr_war_file.stat.exists
- name: Ensure Solr install files are owned by the solr_user.
file:
path: "{{ solr_install_path }}"
owner: "{{ solr_user }}"
group: "{{ solr_user }}"
recurse: yes
when: not solr_war_file.stat.exists
# Set up solr_home.
- name: Check if solr_home is already set up.
stat: "path={{ solr_home }}/solr.xml"
register: solr_example
- name: Ensure solr_home directory exists.
file:
path: "{{ solr_home }}"
state: directory
owner: "{{ solr_user }}"
group: "{{ solr_user }}"
mode: 0755
when: not solr_example.stat.exists
- 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] == '4'"
- name: Ensure Solr home files are owned by the solr_user.
file:
path: "{{ solr_home }}"
owner: "{{ solr_user }}"
group: "{{ solr_user }}"
recurse: yes
when: not solr_example.stat.exists
# Set up Solr init script.
- 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 }}-pre5.j2"
dest: "/etc/init.d/{{ solr_service_name }}"
mode: 0755
- name: Ensure daemon is installed (Debian).
apt: name=daemon state=installed
when: ansible_os_family == "Debian"
- name: Copy solr systemd unit file into place (for systemd systems).
template:
src: solr.unit.j2
dest: /etc/systemd/system/solr.service
owner: root
group: root
mode: 0755
when: >
(ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04') or
(ansible_distribution == 'Debian' and ansible_distribution_version|int >= 8) or
(ansible_distribution == 'CentOS' and ansible_distribution_version|int >= 7) or
(ansible_distribution == 'Fedora')

View file

@ -0,0 +1,37 @@
---
- name: Ensure lsof is present (RedHat).
yum: name=lsof state=present
when: ansible_os_family == "RedHat"
- name: Ensure setfacl support is present.
package: name=acl state=present
- name: Run Solr installation script.
shell: >
{{ solr_workspace }}/{{ solr_filename }}/bin/install_solr_service.sh
{{ solr_workspace }}/{{ solr_filename }}.tgz
-i {{ solr_install_dir }}
-d {{ solr_home }}
-u {{ solr_user }}
-s {{ solr_service_name }}
-p {{ solr_port }}
creates={{ solr_install_path }}/bin/solr
register: solr_install_script_result
# Workaround for bug https://github.com/ansible/ansible-modules-core/issues/915.
- name: Ensure solr is stopped (RHEL 7 workaround).
command: service {{ solr_service_name }} stop
when: >
(ansible_os_family == 'RedHat')
and (ansible_distribution_version.split(".")[0] == '7')
and (solr_install_script_result.changed)
failed_when: false
- name: Run systemd daemon_reload (RHEL 7 workaround).
systemd:
name: solr
daemon_reload: yes
when: >
(ansible_os_family == 'RedHat')
and (ansible_distribution_version.split(".")[0] == '7')
and (solr_install_script_result.changed)

View file

@ -0,0 +1,58 @@
---
- include: user.yml
when: solr_create_user
- name: Set solr_filename for Solr 4+.
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 }}"
when: "solr_version.split('.')[0] == '3'"
- name: Check if Solr has been installed already.
stat:
path: "{{ solr_install_path }}"
register: solr_install_path_status
- name: Download Solr.
get_url:
url: "{{ solr_mirror }}/lucene/solr/{{ solr_version }}/{{ solr_filename }}.tgz"
dest: "{{ solr_workspace }}/{{ solr_filename }}.tgz"
force: no
when: solr_install_path_status.stat.isdir is not defined
register: solr_download_status
- name: Expand Solr.
unarchive:
src: "{{ solr_workspace }}/{{ solr_filename }}.tgz"
dest: "{{ solr_workspace }}"
copy: no
when: solr_download_status.changed
# Install Solr < 5.
- include: install-pre5.yml
when: "solr_version.split('.')[0] < '5'"
# Install Solr 5+.
- include: install.yml
when: "solr_version.split('.')[0] >= '5'"
- name: Ensure solr is started and enabled on boot.
service:
name: "{{ solr_service_name }}"
state: started
enabled: yes
# Configure solr.
- include: configure.yml
when: "solr_version.split('.')[0] >= '5'"
# Create cores, if any are configured.
- include: cores.yml
when: "solr_cores and solr_version.split('.')[0] >= '5'"
- include: trim-fat.yml
static: no

View file

@ -0,0 +1,17 @@
---
- name: Remove the downloaded Solr archive.
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ solr_workspace }}/{{ solr_filename }}.tgz"
- "{{ solr_workspace }}/{{ solr_filename }}"
- name: Remove extra cruft, if configured.
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ solr_install_path }}/docs"
- "{{ solr_install_path }}/example"
when: solr_remove_cruft

View file

@ -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 }}"

View file

@ -0,0 +1,94 @@
#!/bin/sh
# chkconfig: 2345 95 05
# description: Controls an Apache Solr process.
#
# This script will launch Solr in a mode that will automatically respawn if it
# crashes. Output will be sent to $LOG_FILE. A PID file will be created in the
# standard location.
#
# Adapted by Jeff Geerling from http://stackoverflow.com/a/8014720/100134
### BEGIN INIT INFO
# Provides: {{ solr_service_name }}
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache Solr search server
### END INIT INFO
SOLR_DIR="{{ solr_install_path }}/example"
JAVA_OPTIONS="-Dsolr.solr.home={{ solr_home }} -Djetty.host={{ solr_host }} -Djetty.port={{ solr_port }} -Xms{{ solr_xms }} -Xmx{{ solr_xmx }}"
START_COMMAND="java -jar $JAVA_OPTIONS start.jar"
LOG_FILE="{{ solr_log_file_path }}"
start () {
echo -n "Starting {{ solr_service_name }}... "
daemon --chdir="$SOLR_DIR" --command "$START_COMMAND" --respawn --output=$LOG_FILE --name={{ solr_service_name }}
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
stop () {
echo -n "Stopping {{ solr_service_name }}... "
daemon --stop --name={{ solr_service_name }}
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
restart () {
echo -n "Restarting solr... "
daemon --restart --name={{ solr_service_name }}
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
check_status () {
# Report on the status of the daemon
daemon --running --name={{ solr_service_name }} --verbose
return $?
}
case "$1" in
start)
start
;;
status)
check_status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit $RETVAL

View file

@ -0,0 +1,91 @@
#!/bin/sh
# chkconfig: 2345 95 05
# description: Controls an Apache Solr process.
#
# TODO: Describe this file.
#
# @author Jeff Geerling, 2015
. /etc/rc.d/init.d/functions
SOLR_DIR="{{ solr_install_path }}/example"
JAVA_OPTIONS="-Dsolr.solr.home={{ solr_home }} -Djetty.host={{ solr_host }} -Djetty.port={{ solr_port }} -Xms{{ solr_xms }} -Xmx{{ solr_xmx }} -DSTOP.PORT=8079 -DSTOP.KEY=secret"
START_COMMAND="java -jar $JAVA_OPTIONS start.jar"
STOP_COMMAND="java -jar $JAVA_OPTIONS $SOLR_DIR/start.jar --stop"
LOG_FILE="{{ solr_log_file_path }}"
start () {
echo -n "Starting solr... "
if ps aux | grep "[s]olr.solr.home" > /dev/null
then
echo -n "already started... "
else
cd "$SOLR_DIR" && daemon --user="{{ solr_user }}" $START_COMMAND > $LOG_FILE &
fi
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
stop () {
echo -n "Stopping solr... "
if ps aux | grep "[s]olr.solr.home" > /dev/null
then
$STOP_COMMAND
else
echo -n "already stopped... "
fi
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
restart () {
$0 stop
sleep 3
$0 start
}
check_status () {
if ps aux | grep "[s]olr.solr.home" > /dev/null
then
printf "Solr is running.\n"
else
printf "Solr is stopped.\n"
fi
}
case "$1" in
start)
start
;;
status)
check_status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit $RETVAL

View file

@ -0,0 +1,14 @@
[Unit]
Description=Apache SOLR
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
PIDFile={{ solr_install_path }}/bin/solr-{{ solr_port }}.pid
ExecStart={{ solr_install_path }}/bin/solr -e cloud -noprompt
User=solr
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

View file

@ -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)`

View file

@ -0,0 +1,2 @@
---
- src: geerlingguy.java

View file

@ -0,0 +1,11 @@
---
- hosts: all
vars:
solr_version: "3.6.2"
java_packages:
- openjdk-7-jdk
roles:
- geerlingguy.java
- role_under_test

View file

@ -0,0 +1,11 @@
---
- hosts: all
vars:
solr_version: "4.10.4"
java_packages:
- openjdk-7-jdk
roles:
- geerlingguy.java
- role_under_test

View file

@ -0,0 +1,20 @@
---
- hosts: all
vars:
solr_version: "5.5.3"
solr_remove_cruft: true
java_packages:
- openjdk-7-jdk
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == "Debian"
- name: Ensure sudo is present.
package: name=sudo state=present
roles:
- geerlingguy.java
- role_under_test

View file

@ -0,0 +1,47 @@
---
- hosts: all
pre_tasks:
- name: Set Java 8 package for RedHat.
set_fact:
java_packages:
- java-1.8.0-openjdk
when: ansible_os_family == "RedHat"
- name: Set Java 8 package for Debian/Ubuntu.
set_fact:
java_packages:
- openjdk-8-jdk
when: >
ansible_distribution == "Debian" or
(ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04")
- name: Add repository for OpenJDK 8 (Ubuntu 14.04).
apt_repository: repo='ppa:openjdk-r/ppa'
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04"
- name: Enable Backports repository (Debian).
apt_repository:
repo: 'deb http://ftp.debian.org/debian {{ ansible_distribution_release }}-backports main'
state: present
filename: "{{ ansible_distribution_release }}_backports"
register: debian_backports
when: ansible_distribution == "Debian"
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == "Debian"
# See: http://unix.stackexchange.com/a/342469
- name: Install dependencies (Debian).
apt:
default_release: "{{ ansible_distribution_release }}-backports"
name:
- openjdk-8-jre-headless
- ca-certificates-java
state: present
when: ansible_distribution == "Debian"
roles:
- geerlingguy.java
- role_under_test