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