2018-06-04 23:35:02 -05:00
|
|
|
---
|
2018-08-08 01:11:51 -05:00
|
|
|
# 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.
|
|
|
|
|
2018-07-16 14:55:14 -05:00
|
|
|
- name: Create/Setup known indexes in Elasticsearch
|
2018-06-04 23:35:02 -05:00
|
|
|
hosts: "elastic-logstash[0]"
|
|
|
|
become: true
|
|
|
|
|
2018-09-21 20:06:52 -05:00
|
|
|
vars:
|
|
|
|
elastic_refresh_interval: "{{ (elasticsearch_number_of_replicas | int) * 5 }}"
|
|
|
|
|
2018-06-04 23:35:02 -05:00
|
|
|
vars_files:
|
|
|
|
- vars/variables.yml
|
|
|
|
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
|
2018-08-08 01:11:51 -05:00
|
|
|
roles:
|
|
|
|
- role: elastic_retention
|
2018-07-26 19:20:57 -05:00
|
|
|
|
2018-08-08 01:11:51 -05:00
|
|
|
post_tasks:
|
2018-06-04 23:35:02 -05:00
|
|
|
- name: Create basic indexes
|
|
|
|
uri:
|
|
|
|
url: http://127.0.0.1:9200/{{ item.name }}
|
|
|
|
method: PUT
|
|
|
|
body: "{{ item.index_options | to_json }}"
|
|
|
|
status_code: 200,400
|
|
|
|
body_format: json
|
2018-07-09 13:58:23 -05:00
|
|
|
register: elk_indexes
|
|
|
|
until: elk_indexes is success
|
|
|
|
retries: 3
|
2018-08-15 21:35:31 -05:00
|
|
|
delay: 10
|
2018-06-04 23:35:02 -05:00
|
|
|
with_items:
|
|
|
|
- name: "osprofiler-notifications"
|
|
|
|
index_options:
|
|
|
|
settings:
|
|
|
|
index:
|
|
|
|
codec: "best_compression"
|
|
|
|
mapping:
|
|
|
|
total_fields:
|
|
|
|
limit: "10000"
|
|
|
|
refresh_interval: "5s"
|
2018-07-16 14:55:14 -05:00
|
|
|
- name: "_all/_settings?preserve_existing=true"
|
|
|
|
index_options:
|
2018-07-24 17:46:15 -05:00
|
|
|
index.queries.cache.enabled: "true"
|
|
|
|
indices.queries.cache.size: "5%"
|
2018-07-26 19:20:57 -05:00
|
|
|
- name: "_all/_settings"
|
|
|
|
index_options:
|
2018-08-02 15:41:12 -05:00
|
|
|
index.number_of_replicas: "{{ elasticsearch_number_of_replicas | int }}"
|
2018-09-21 20:06:52 -05:00
|
|
|
index.translog.durability: "async"
|
|
|
|
index.refresh_interval: "{{ ((elastic_refresh_interval | int) > 30) | ternary(30, elastic_refresh_interval) }}s"
|
2018-08-15 21:35:31 -05:00
|
|
|
|
|
|
|
- name: Check for basic index template
|
|
|
|
uri:
|
|
|
|
url: http://127.0.0.1:9200/_template/basic-index-template
|
|
|
|
method: HEAD
|
|
|
|
failed_when: false
|
|
|
|
register: check_basicIndexTemplate
|
|
|
|
register: check_basicIndexTemplate
|
|
|
|
until: check_basicIndexTemplate is success
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
|
|
|
|
|
|
|
- name: Check for basic index template
|
|
|
|
uri:
|
|
|
|
url: http://127.0.0.1:9200/_template/basic-index-template
|
|
|
|
method: DELETE
|
|
|
|
status_code: 200
|
|
|
|
register: delete_basicIndexTemplate
|
|
|
|
until: delete_basicIndexTemplate is success
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
|
|
|
when:
|
|
|
|
- check_basicIndexTemplate.status == 200
|
|
|
|
|
|
|
|
- name: Create basic index template
|
|
|
|
uri:
|
|
|
|
url: http://127.0.0.1:9200/_template/basic-index-template
|
|
|
|
method: PUT
|
|
|
|
body: "{{ index_option | to_json }}"
|
|
|
|
status_code: 200
|
|
|
|
body_format: json
|
|
|
|
register: create_basicIndexTemplate
|
|
|
|
until: create_basicIndexTemplate is success
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
|
|
|
vars:
|
|
|
|
index_option:
|
|
|
|
index_patterns: >-
|
|
|
|
{{
|
|
|
|
(elastic_beat_retention_policy_hosts.keys() | list)
|
|
|
|
| map('regex_replace', '(.*)', '\1-' ~ '*')
|
|
|
|
| list
|
|
|
|
}}
|
|
|
|
settings:
|
|
|
|
number_of_replicas: "{{ elasticsearch_number_of_replicas | int }}"
|
2018-08-17 15:30:11 -05:00
|
|
|
index:
|
|
|
|
mapping:
|
|
|
|
total_fields:
|
|
|
|
limit: "3072"
|
2018-09-19 12:02:05 -05:00
|
|
|
|
|
|
|
- name: Create custom monitoring index template
|
|
|
|
uri:
|
|
|
|
url: http://127.0.0.1:9200/_template/custom_monitoring
|
|
|
|
method: PUT
|
|
|
|
body: "{{ index_option | to_json }}"
|
|
|
|
status_code: 200
|
|
|
|
body_format: json
|
|
|
|
register: create_basicIndexTemplate
|
|
|
|
until: create_basicIndexTemplate is success
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
|
|
|
vars:
|
|
|
|
index_option:
|
|
|
|
template: ".monitoring-*"
|
|
|
|
order: 1
|
|
|
|
settings:
|
|
|
|
number_of_replicas: "{{ elasticsearch_number_of_replicas | int }}"
|
|
|
|
number_of_shards: "{{ ((elasticsearch_number_of_replicas | int) * 2) + 1 }}"
|