360b35a08f
* Fix error messages with ES results * Add lsof for debugging * Add torrents table variable to index sukebei * Use elasticsearch alias for hotswapping index * Increase max open files, increase ES heap size * Add reindex script and reindex triggers We use a table to store the actions happened to the torrents table. When the torrents table is INSERTED/UPDATED/DELETED, the trigger kicks in and an entry is made to the reindex_torrents table. The reindex_nyaapantsu.py script is then used to query the reindex_torrents table and apply the correct reindex action to elasticsearch. The entries are then removed for reindex_torrents table. * Reindex every 5 minutes as cronjob
87 lignes
2,2 Kio
YAML
87 lignes
2,2 Kio
YAML
- name: Add elasticsearch key
|
|
rpm_key:
|
|
state: present
|
|
key: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
become: true
|
|
|
|
- name: Add elasticsearch repo
|
|
yum_repository:
|
|
name: elasticsearch-5.x
|
|
baseurl: https://artifacts.elastic.co/packages/5.x/yum
|
|
gpgcheck: 1
|
|
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
enabled: 1
|
|
description: Elastic search repository for 5.x packages
|
|
become: true
|
|
|
|
- name: Install java and elasticsearch
|
|
yum:
|
|
name: "{{ item }}"
|
|
state: present
|
|
become: true
|
|
with_items:
|
|
- java-1.8.0-openjdk
|
|
- elasticsearch
|
|
- python-elasticsearch # INFO Needed for index_nyaapantsu.py script
|
|
|
|
- name: Copy files to remote
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: "{{ nyaapantsu_directory }}"
|
|
with_items:
|
|
- elasticsearch_settings.yml
|
|
- index_nyaapantsu.py
|
|
|
|
- name: Increase system max open files
|
|
lineinfile:
|
|
path: /etc/sysctl.conf
|
|
regexp: '^fs.file-max.*'
|
|
line: 'fs.file-max = {{ nyaapantsu_max_open_files }}'
|
|
become: true
|
|
|
|
- name: Increase JVM heapsize
|
|
lineinfile:
|
|
path: /etc/sysconfig/elasticsearch
|
|
regexp: '^ES_JAVA_OPTS=.*'
|
|
line: 'ES_JAVA_OPTS="-Xms{{ nyaapantsu_jvm_heapsize_gb }}g -Xmx{{ nyaapantsu_jvm_heapsize_gb }}g"'
|
|
become: true
|
|
|
|
- name: Create override folder
|
|
file:
|
|
path: /etc/systemd/system/elasticsearch.service.d/
|
|
state: directory
|
|
mode: 0755
|
|
become: true
|
|
|
|
- name: Add override service file
|
|
template:
|
|
src: elasticsearch.override.j2
|
|
dest: /etc/systemd/system/elasticsearch.service.d/override.conf
|
|
become: true
|
|
|
|
- name: Enable and start elasticsearch
|
|
systemd:
|
|
enabled: yes
|
|
name: elasticsearch
|
|
state: started
|
|
daemon_reload: yes
|
|
become: true
|
|
|
|
- name: Copy reindexing triggers
|
|
template:
|
|
src: reindex_triggers.sql.j2
|
|
dest: "{{ nyaapantsu_directory }}/reindex_triggers.sql"
|
|
|
|
- name: Apply reindexing triggers
|
|
shell: psql -U "{{ nyaapantsu_user }}" "{{ nyaapantsu_dbname }}" < "{{ nyaapantsu_directory }}/reindex_triggers.sql"
|
|
|
|
- name: Copy reindexing script
|
|
copy:
|
|
src: reindex_nyaapantsu.py
|
|
dest: "{{ elasticsearch_reindex_script }}"
|
|
|
|
- name: Setup reindexing cron job
|
|
template:
|
|
src: reindex_cron.j2
|
|
dest: "/etc/cron.d/reindex_{{ nyaapantsu_torrent_tablename }}"
|
|
become: true
|