blob: b5df7b91eb2380e27b7638c22dfa9863103eb4be [file] [log] [blame]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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: Add Elasticsearch GPG key
rpm_key:
key: https://packages.elastic.co/GPG-KEY-elasticsearch
state: present
- name: Add Elasticsearch repository
copy:
src: elasticsearch.repo
dest: /etc/yum.repos.d/elasticsearch.repo
mode: 0644
- name: Install Elasticsearch
yum:
name: elasticsearch
state: installed
register: result
until: result.rc == 0
retries: 5
delay: 10
- name: Create Data Directories
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: elasticsearch
group: elasticsearch
when: elasticsearch_data_dir is defined
with_items:
- '{{ elasticsearch_data_dir.split(",") }}'
- name: Configure Elasticsearch - remove stale entries
lineinfile: >
dest=/etc/elasticsearch/elasticsearch.yml
regexp="{{ item }}"
state=absent
with_items:
- '^cluster\.name:'
- '^network\.host:'
- '^discovery\.zen\.ping\.unicast\.hosts:'
- '^path\.data'
- name: Configure Elasticsearch
lineinfile: >
dest=/etc/elasticsearch/elasticsearch.yml
regexp="{{ item.regexp }}"
insertafter="{{ item.regexp }}"
line="{{ item.line }}"
state=present
with_items:
- { regexp: '^# *cluster\.name:', line: 'cluster.name: metron' }
- { regexp: '^# *network\.host:', line: 'network.host: _{{
elasticsearch_network_interface }}:ipv4_' }
- { regexp: '^# *discovery\.zen\.ping\.unicast\.hosts:',
line: 'discovery.zen.ping.unicast.hosts: [ {{ es_hosts }} ]'}
- { regexp: '^# *path\.data', line: 'path.data: {{ elasticsearch_data_dir }}' }