
This allows alternate algorithms to be developed and enables the same tasks to be included in a test to verify the planned retention does not exceed the cluster storage capacity. Change-Id: Ie3d80d6cfad16b946ccd790859bc7cd92b90fdef
153 lines
4.3 KiB
YAML
153 lines
4.3 KiB
YAML
---
|
|
# Copyright 2018, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Install Curator
|
|
hosts: "elastic-logstash"
|
|
become: true
|
|
gather_facts: true
|
|
vars:
|
|
haproxy_ssl: false
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
pre_tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
tags:
|
|
- always
|
|
|
|
- name: Query es storage
|
|
uri:
|
|
url: "http://127.0.0.1:9200/_nodes/{{ (data_nodes | map('extract', hostvars, 'ansible_host') | list) | join(',') }}/stats/fs"
|
|
method: GET
|
|
register: elk_data
|
|
until: elk_data is success
|
|
retries: 5
|
|
delay: 5
|
|
run_once: true
|
|
|
|
- name: Set available storage fact
|
|
set_fact:
|
|
es_total_available_storage: "{{ ((elk_data['json']['nodes'].values() | list) | map(attribute='fs.total.total_in_bytes') | list | sum) // 1024 // 1024 }}"
|
|
|
|
- name: Compute index retention
|
|
include_tasks: "calculate_index_retention_{{ elastic_index_retention_algorithm | default('default') }}.yml"
|
|
|
|
- name: Ensure virtualenv is installed
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: true
|
|
with_items:
|
|
- python-virtualenv
|
|
- virtualenv
|
|
tags:
|
|
- package_install
|
|
|
|
- name: Ensure curator is installed
|
|
pip:
|
|
name: "elasticsearch-curator<6"
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
extra_args: --isolated
|
|
virtualenv: /opt/elasticsearch-curator
|
|
register: _pip_task
|
|
until: _pip_task is success
|
|
retries: 3
|
|
delay: 2
|
|
tags:
|
|
- package_install
|
|
|
|
- name: exit playbook after uninstall
|
|
meta: end_play
|
|
when:
|
|
- (elk_package_state | default('present')) == 'absent'
|
|
|
|
tasks:
|
|
- name: create the system group
|
|
group:
|
|
name: "curator"
|
|
state: "present"
|
|
system: "yes"
|
|
|
|
- name: Create the curator system user
|
|
user:
|
|
name: "curator"
|
|
group: "curator"
|
|
comment: "curator user"
|
|
shell: "/bin/false"
|
|
createhome: "yes"
|
|
home: "/var/lib/curator"
|
|
|
|
- name: Create curator data path
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "curator"
|
|
group: "curator"
|
|
mode: "0755"
|
|
recurse: true
|
|
with_items:
|
|
- "/var/lib/curator"
|
|
- "/var/log/curator"
|
|
- "/etc/curator"
|
|
|
|
- name: Drop curator conf file
|
|
template:
|
|
src: templates/curator.yml.j2
|
|
dest: /var/lib/curator/curator.yml
|
|
|
|
- name: Drop curator action file
|
|
template:
|
|
src: templates/curator-actions.yml.j2
|
|
dest: /var/lib/curator/actions.yml
|
|
|
|
post_tasks:
|
|
- name: Run the systemd service role
|
|
include_role:
|
|
name: systemd_service
|
|
private: true
|
|
vars:
|
|
systemd_service_enabled: "{{ ((elk_package_state | default('present')) != 'absent') | ternary(true, false) }}"
|
|
systemd_service_restart_changed: false
|
|
systemd_user_name: curator
|
|
systemd_group_name: curator
|
|
systemd_services:
|
|
- service_name: "curator"
|
|
execstarts:
|
|
- /opt/elasticsearch-curator/bin/curator
|
|
--config /var/lib/curator/curator.yml
|
|
/var/lib/curator/actions.yml
|
|
timer:
|
|
state: "started"
|
|
options:
|
|
OnBootSec: 30min
|
|
OnUnitActiveSec: 24h
|
|
Persistent: true
|
|
|
|
- name: Enable and restart curator.timer
|
|
systemd:
|
|
name: "curator.timer"
|
|
enabled: true
|
|
state: restarted
|
|
when:
|
|
- (elk_package_state | default('present')) != 'absent'
|
|
tags:
|
|
- config
|
|
|
|
tags:
|
|
- beat-install
|