Add lxc-solr role
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Tristan PILAT 2019-07-02 18:11:54 +02:00
parent 11a039bfac
commit 8de8736dbc
5 changed files with 95 additions and 0 deletions

27
lxc-solr/README.md Normal file
View file

@ -0,0 +1,27 @@
# lxc-solr
Create one or more LXC containers with Solr in the version of your choice.
*note : this role depend on the lxc role.*
## Tasks
Everything is in the `tasks/main.yml` file.
## Available variables
Since this role depend on the lxc role, please refer to it for a full variable list related to the lxc containers setup.
* `lxc_containers`: list of LXC containers to create. Default: `[]` (empty).
* `name`: name of the LXC container to create.
* `release`: Debian version to install
* `solr_version`: Solr version to install *(refer to https://archive.apache.org/dist/lucene/solr/ for a full version list)*
* `solr_port`: port for Solr to listen on
Eg.:
```
lxc_containers:
- name: solr8
release: stretch
solr_version: 6.6.6
solr_port: 8983
```

View file

@ -0,0 +1,18 @@
---
# List of LXC containers to create alongside with the version of Solr to install for each of them
# Eg.:
# lxc_containers:
# - name: solr6
# release: stretch
# solr_version: 6.6.6
# solr_port: 8983
# - name: solr7
# release: stretch
# solr_version: 7.7.2
# solr_port: 8984
# - name: solr8
# release: stretch
# solr_version: 8.1.1
# solr_port: 8985
lxc_containers: []

8
lxc-solr/tasks/main.yml Normal file
View file

@ -0,0 +1,8 @@
---
- name: LXC configuration
include_role:
name: lxc
- include: "solr.yml name={{item.name}} solr_version={{item.solr_version}} solr_port={{item.solr_port}}"
with_items:
- "{{ lxc_containers }}"

39
lxc-solr/tasks/solr.yml Normal file
View file

@ -0,0 +1,39 @@
---
- name: "Change default ulimit for container {{ name }}"
blockinfile:
dest: "/var/lib/lxc/{{ name }}/rootfs/root/.bashrc"
marker: "# {mark} set ulimit for Solr"
block: |
ulimit -n 65000
ulimit -u 65000
- name: Install openjdk-8-jre-headless package
command: "lxc-attach -n {{name}} -- apt-get install -y openjdk-8-jre-headless"
- name: "Download Solr {{ solr_version }}"
get_url:
url: "https://archive.apache.org/dist/lucene/solr/{{ solr_version }}/solr-{{ solr_version }}.tgz"
dest: "/var/lib/lxc/{{ name }}/rootfs/root/solr-{{ solr_version }}.tgz"
mode: '0644'
- name: "Extract solr-{{ solr_version }}.tgz"
unarchive:
src: /var/lib/lxc/{{ name }}/rootfs/root/solr-{{ solr_version }}.tgz
dest: /var/lib/lxc/{{ name }}/rootfs/opt/
remote_src: yes
- name: Set Solr autostart
template:
src: rc.local.j2
dest: "/var/lib/lxc/{{ name }}//rootfs/etc/rc.local"
mode: "0755"
- name: Check if Solr is running
command: "lxc-attach -n {{name}} -- /opt/solr-{{ solr_version }}/bin/solr status"
ignore_errors: yes
changed_when: false
register: service_solr_status
- name: "Start Solr {{ solr_version }}"
command: "lxc-attach -n {{name}} -- /opt/solr-{{ solr_version }}/bin/solr start -p {{ solr_port }} -force"
when: service_solr_status | failed

View file

@ -0,0 +1,3 @@
#!/bin/bash
/opt/solr-{{ solr_version }}/bin/solr start -p {{ solr_port }} -force
exit 0