Skip to content

Instantly share code, notes, and snippets.

@jp1987
Created January 11, 2017 13:43
Show Gist options
  • Save jp1987/9de3149616e50d31138fdc73bb2337f6 to your computer and use it in GitHub Desktop.
Save jp1987/9de3149616e50d31138fdc73bb2337f6 to your computer and use it in GitHub Desktop.
TYPO3 solr ansible playbook
---
- name: restart-solr
service:
name: solr
state: restarted
become: yes
---
- name: Install dependencies
apt:
pkg: "{{ item }}"
state: latest
with_items:
- default-jre
- unzip
become: yes
- name: Download solr
get_url:
url: "http://archive.apache.org/dist/lucene/solr/{{ solr_version }}/solr-{{ solr_version }}.tgz"
dest: "/root/solr-{{ solr_version }}.tgz"
become: yes
- name: Extract install script
command: tar xzf solr-{{ solr_version }}.tgz solr-{{ solr_version }}/bin/install_solr_service.sh --strip-components=2
args:
chdir: /root
creates: /root/install_solr_service.sh
warn: off
become: yes
- name: Run install script
command: ./install_solr_service.sh solr-{{ solr_version }}.tgz
args:
chdir: /root
creates: /etc/init.d/solr
become: yes
- name: Create standard cores
command: ./solr create_core -c {{ item }} -d basic_configs
args:
chdir: /opt/solr/bin
creates: /var/solr/data/{{ item }}/core.properties
become: yes
with_items: "{{ solr_standard_cores | default({}) }}"
become_user: solr
tags: solr-cores
- name: Download TYPO3 solr ext
get_url:
url: "https://github.com/TYPO3-Solr/ext-solr/archive/{{ solr_typo3_version }}.zip"
dest: "/root/typo3solr-{{ solr_typo3_version }}.zip"
become: yes
when: solr_typo3|bool
tags: solr-cores
- name: Extract TYPO3 solr ext
command: "unzip /root/typo3solr-{{ solr_typo3_version }}.zip"
args:
chdir: /root
warn: off
creates: "/root/ext-solr-{{ solr_typo3_version }}/ext_emconf.php"
become: yes
when: solr_typo3|bool
- name: Copy configset
command: "cp -r /root/ext-solr-{{ solr_typo3_version }}/Resources/Private/Solr/configsets /var/solr/data/configsets/"
args:
creates: "/var/solr/data/configsets/ext_solr_{{ solr_typo3_version | replace('.', '_') }}/conf/solrconfig.xml"
become: yes
when: solr_typo3|bool
tags: solr-cores
- name: Copy solr.xml
command: "cp /root/ext-solr-{{ solr_typo3_version }}/Resources/Private/Solr/solr.xml /opt/solr/server/solr/solr.xml"
changed_when: false
become: yes
when: solr_typo3|bool
tags: solr-cores
- name: Create core directories
file:
path: "/var/solr/data/{{ item.core_name }}/"
state: directory
owner: solr
group: solr
become: yes
with_items: "{{ solr_typo3_cores | default({}) }}"
when: solr_typo3|bool
tags: solr-cores
- name: Create core
command: "cp /root/ext-solr-{{ solr_typo3_version }}/Resources/Private/Solr/cores/{{ item.language }}/core.properties /var/solr/data/{{ item.core_name }}/core.properties"
changed_when: false
become: yes
with_items: "{{ solr_typo3_cores | default({}) }}"
when: solr_typo3|bool
tags: solr-cores
- name: Set core permissions
file:
path: "/var/solr/data/{{ item.core_name }}/core.properties"
state: file
owner: solr
group: solr
become: yes
with_items: "{{ solr_typo3_cores | default({}) }}"
when: solr_typo3|bool
tags: solr-cores
notify: restart-solr
solr_version: 6.3.0
solr_standard_cores: []
solr_typo3: true
solr_typo3_version: 6.0.0
solr_typo3_cores:
- language: english
core_name: core_en
- language: german
core_name: core_de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment