ansible-roles/solr/tasks/main.yml

58 lines
2.0 KiB
YAML

---
- block:
- name: Create a solr user
user: name={{ solr_user }} home={{ solr_base_dir }} createhome=yes shell=/bin/bash
- name: Download solr
get_url: url='{{ solr_download_url }}' dest={{ solr_download_dir }}/solr-{{ solr_version }}.tgz validate_certs=no
- name: Unarchive solr release
unarchive: src={{ solr_download_dir }}/solr-{{ solr_version }}.tgz dest={{ solr_base_dir }} copy=no
args:
creates: '{{ solr_base_dir }}/bin/solr'
- name: Link to the latest release
file: src={{ solr_base_dir }}/solr-{{ solr_version }} dest={{ solr_server_dir }} state=link
- name: Create the solr service, download, data and logs directories
file: path={{ item }} state=directory owner={{ solr_user }} group={{ solr_user }}
with_items:
- '{{ solr_download_dir }}'
- '{{ solr_data_dir }}'
- '{{ solr_pid_dir }}'
- '{{ solr_log_dir }}'
- name: Fix the permissions of the solr server directory
file: dest={{ solr_data_dir }} state=directory owner={{ solr_user }} group={{ solr_user }} recurse=yes
- name: Create the solr lib directory
file: dest={{ solr_data_dir }}/lib state=directory
- name: Install the zookeeper configuration
template: src={{ item }}.j2 dest={{ solr_data_dir }}/{{ item }}
with_items:
- solr.xml
- zoo.cfg
notify: solr restart
- name: copy extra libraries
shell: cd {{ solr_server_dir }}; cp -u {{ item }} {{ solr_data_dir }}/lib
with_items: '{{ solr_jar_files }}'
- name: install the solr init script
copy: src=solr dest=/etc/init.d/solr mode=0755 owner=root group=root
- name: Install the solr default
template: src=solr-default.j2 dest=/etc/default/solr.in.sh mode=0644 owner=root group=root
notify: solr restart
tags: [ 'solr', 'solr_default' ]
- name: Start and enable the solr service
service: name=solr state=started enabled=yes
ignore_errors: True
become: True
become_user: root
when: solr_install
tags: solr