2019-04-18 12:02:09 -07:00
|
|
|
|
|
|
|
|
|
|
|
- name: Install Elasticsearch
|
|
|
|
hosts: elastic
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Install Elastic GPG Key
|
|
|
|
become: true
|
|
|
|
apt_key:
|
|
|
|
url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
|
|
|
|
state: present
|
|
|
|
id: 46095ACC8548582C1A2699A9D27D666CD88E42B4
|
|
|
|
|
|
|
|
- name: Install apt-transport-https
|
|
|
|
apt:
|
|
|
|
name: apt-transport-https
|
|
|
|
- name: Add Elastic Repo
|
|
|
|
become: true
|
|
|
|
copy:
|
|
|
|
src: elastic-7.x.list
|
|
|
|
dest: /etc/apt/sources.list.d/
|
|
|
|
backup: yes
|
|
|
|
|
|
|
|
- name: Update Packages
|
|
|
|
become: true
|
|
|
|
apt:
|
|
|
|
update_cache: true
|
|
|
|
|
|
|
|
- name: Install ElasticSearch
|
|
|
|
become: true
|
|
|
|
apt:
|
|
|
|
name: elasticsearch
|
|
|
|
|
2019-04-19 09:07:35 -07:00
|
|
|
|
|
|
|
# This will work on a new install.
|
|
|
|
# If any changes are needed to the cluster name on an existing install add another function
|
|
|
|
- name: Config - cluster.name 'elastic-DMI01'
|
|
|
|
become: true
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/elasticsearch/elasticsearch.yml
|
|
|
|
regex: '^cluster.name'
|
|
|
|
insertafter: '#cluster.name: my-application'
|
|
|
|
line: 'cluster.name: elastic-DMI01'
|
|
|
|
backup: yes
|
|
|
|
|
|
|
|
- name: Config - node.name
|
|
|
|
become: true
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/elasticsearch/elasticsearch.yml
|
|
|
|
regex: '^node.name'
|
|
|
|
insertafter: '#node.name: node-1'
|
|
|
|
line: "node.name: {{ ansible_eno1.ipv4.address }}"
|
|
|
|
|
2019-04-18 13:49:30 -07:00
|
|
|
- name: Allow port 9200 though UFW
|
|
|
|
become: true
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 9200
|
|
|
|
#name: ElasticSearch
|
|
|
|
|
|
|
|
- name: Service reload daemon
|
|
|
|
become: true
|
2019-04-18 12:02:09 -07:00
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
2019-04-18 13:49:30 -07:00
|
|
|
|
2019-04-19 09:16:55 -07:00
|
|
|
- name: systemd - enable ElasticSearch on startup
|
2019-04-18 13:49:30 -07:00
|
|
|
become: true
|
|
|
|
systemd:
|
2019-04-18 12:02:09 -07:00
|
|
|
name: elasticsearch
|
2019-04-18 13:49:30 -07:00
|
|
|
enabled: yes
|
2019-04-18 12:02:09 -07:00
|
|
|
|
2019-04-19 09:16:55 -07:00
|
|
|
- name: systemd - restart ElasticSearch service
|
|
|
|
become: true
|
|
|
|
systemd:
|
|
|
|
name: elasticsearch
|
|
|
|
state: restarted
|
2019-04-18 12:02:09 -07:00
|
|
|
|