Skip to content

Commit d7971bd

Browse files
author
Jonathan Strootman
committed
Updating to install 2.x, support CentOS 7 install
1 parent 085bb55 commit d7971bd

File tree

9 files changed

+90
-30
lines changed

9 files changed

+90
-30
lines changed

defaults/main.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33

44
elasticsearch_user: elasticsearch
55
elasticsearch_group: elasticsearch
6-
elasticsearch_download_url: https://download.elasticsearch.org/elasticsearch/elasticsearch
76
elasticsearch_version: 1.7.3
87
elasticsearch_apt_repos:
98
- 'ppa:webupd8team/java'
10-
elasticsearch_apt_java_package: oracle-java7-installer
11-
elasticsearch_apt_dependencies:
12-
- htop
13-
- ntp
14-
- unzip
9+
elasticsearch_java_package: oracle-java7-installer
10+
elasticsearch_pkg_dependencies:
11+
- htop
12+
- ntp
13+
- unzip
14+
elasticsearch_ubuntu_download_url: https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/{{elasticsearch_version}}/elasticsearch-{{elasticsearch_version}}.deb
15+
elasticsearch_centos7_download_url: https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/{{elasticsearch_version}}/elasticsearch-{{elasticsearch_version}}.rpm
1516
elasticsearch_max_open_files: 65535
1617
elasticsearch_home_dir: /usr/share/elasticsearch
1718
elasticsearch_plugin_dir: /usr/share/elasticsearch/plugins

meta/main.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ galaxy_info:
44
author: "George Stathis"
55
company: Traackr
66
license: MIT
7-
min_ansible_version: 1.3
7+
min_ansible_version: 1.9
88
platforms:
99
- name: Ubuntu
1010
versions:
1111
- precise
12+
- name: CentOS
13+
versions:
14+
- 7
1215
categories:
1316
- database:nosql
1417
dependencies: []

tasks/custom-jars.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
# - ...
1111

1212
# Loop though elasticsearch_custom_jars and install them
13-
- name: Installing Custom JARs
13+
- name: custom jars | Installing Custom JARs
1414
action: >
1515
get_url url={{ item.uri }}
1616
url_username={{ item.user }} url_password={{ item.passwd }} dest="{{ elasticsearch_home_dir }}/lib/{{ item.filename }}"
1717
with_items: elasticsearch_custom_jars
1818
# Fix permissions
19-
- file: >
19+
- name: custom jars |
20+
file: >
2021
path="{{ elasticsearch_home_dir }}/lib" state=directory
2122
owner={{ elasticsearch_user }} group={{ elasticsearch_group }}
2223
recurse=yes

tasks/elastic-install.yml

+48-14
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
state=present
77
update_cache=yes
88
cache_valid_time={{apt_cache_valid_time}}
9+
when: ansible_distribution == "Ubuntu"
910

1011
- name: elastic-install | Install dependencies
11-
apt:
12-
pkg={{ item }}
13-
state=present
14-
with_items: elasticsearch_apt_dependencies
12+
action: >
13+
{{ ansible_pkg_mgr }}
14+
name={{ item }}
15+
state=present
16+
with_items: "{{ elasticsearch_pkg_dependencies }}"
1517

1618
- name: elastic-install | Configuring elastic group
1719
group:
@@ -45,14 +47,26 @@
4547

4648
- name: elastic-install | Download Elasticsearch deb
4749
get_url:
48-
url={{ elasticsearch_download_url }}/elasticsearch-{{ elasticsearch_version }}.deb
49-
dest=/tmp/elasticsearch-{{ elasticsearch_version }}.deb
50+
url={{ elasticsearch_ubuntu_download_url }}
51+
dest=/tmp/
5052
mode=0440
51-
when: not installed_version.stat.exists
53+
register: downloaded_pkg
54+
when: not installed_version.stat.exists and
55+
ansible_distribution == "Ubuntu"
56+
57+
- name: elastic-install | Download Elasticsearch rpm
58+
get_url:
59+
url={{ elasticsearch_centos7_download_url }}
60+
dest=/tmp/
61+
mode=0440
62+
register: downloaded_pkg
63+
when: not installed_version.stat.exists and
64+
ansible_distribution == "CentOS" and
65+
ansible_distribution_major_version == "7"
5266

53-
#shell: dpkg --remove elasticsearch
5467
- name: elastic-install | Uninstalling previous version if applicable
55-
apt:
68+
action: >
69+
{{ ansible_pkg_mgr }}
5670
name="elasticsearch"
5771
state="absent"
5872
when: not installed_version.stat.exists
@@ -63,9 +77,17 @@
6377
state=absent
6478
when: not installed_version.stat.exists
6579

66-
- name: elastic-install | Install Elasticsearch deb
67-
shell: dpkg -i -E --force-confnew /tmp/elasticsearch-{{ elasticsearch_version }}.deb
68-
when: not installed_version.stat.exists
80+
- name: elastic-install | Ubuntu | Install Elasticsearch deb
81+
shell: dpkg -i -E --force-confnew {{ downloaded_pkg.dest }}
82+
when: not installed_version.stat.exists and
83+
ansible_distribution == "Ubuntu"
84+
notify: Restart Elasticsearch
85+
86+
- name: elastic-install | CentOS-7 | Install Elasticsearch rpm
87+
shell: rpm -i {{ downloaded_pkg.dest }}
88+
when: not installed_version.stat.exists and
89+
ansible_distribution == "CentOS" and
90+
ansible_distribution_major_version == "7"
6991
notify: Restart Elasticsearch
7092

7193
- name: elastic-install | Ensure elastic directories exists
@@ -83,7 +105,7 @@
83105
- "{{ elasticsearch_work_dir }}"
84106
- "{{ elasticsearch_conf_dir }}"
85107

86-
- name: Configure limits max_open_files
108+
- name: elastic-install | Configure limits max_open_files
87109
lineinfile:
88110
dest=/etc/security/limits.conf
89111
regexp='^{{ elasticsearch_user }} - nofile {{ elasticsearch_max_open_files }}'
@@ -116,6 +138,7 @@
116138
insertafter=EOF
117139
line='session required pam_limits.so'
118140
notify: Restart Elasticsearch
141+
when: ansible_distribution == "Ubuntu"
119142

120143
- name: elastic-install | Configure common-session-noninteractive pam_limits.so
121144
lineinfile:
@@ -124,6 +147,17 @@
124147
insertafter=EOF
125148
line='session required pam_limits.so'
126149
notify: Restart Elasticsearch
150+
when: ansible_distribution == "Ubuntu"
151+
152+
- name: elastic-install | Configure system-auth pam_limits.so
153+
lineinfile:
154+
dest=/etc/pam.d/system-auth
155+
regexp='^session required pam_limits.so'
156+
insertafter=EOF
157+
line='session required pam_limits.so'
158+
notify: Restart Elasticsearch
159+
when: ansible_distribution == "CentOS" and
160+
ansible_distribution_major_version == "7"
127161

128162
- name: elastic-install | Configure sudo pam_limits.so
129163
lineinfile:
@@ -158,4 +192,4 @@
158192
owner={{ elasticsearch_user }}
159193
group={{ elasticsearch_group }}
160194
mode=0644
161-
notify: Restart Elasticsearch
195+
notify: Restart Elasticsearch

tasks/java.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
- name: java | Accept Oracle license prior JDK installation
44
shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections; echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
55
creates=/usr/lib/jvm/java-8-oracle
6+
when: ansible_distribution == "Ubuntu"
67

78
- name: java | Update repositories
89
apt_repository:
910
repo={{ item }}
1011
state=present
1112
update_cache=yes
1213
with_items: elasticsearch_apt_repos
14+
when: ansible_distribution == "Ubuntu"
1315

1416
- name: java | Install dependencies
15-
apt:
16-
pkg={{elasticsearch_apt_java_package}}
17+
action: >
18+
{{ansible_pkg_mgr}}
19+
name={{elasticsearch_java_package}}
1720
state=present

tasks/main.yml

+17
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,45 @@
44
# Install Java
55
- include: java.yml
66
when: elasticsearch_install_java
7+
tags:
8+
- java
79

810
# Configure timezome
911
- include: timezone.yml
12+
tags:
13+
- timezone
1014

1115
# Install and configure elasticsearch
1216
- include: elastic-install.yml
17+
tags:
18+
- install
1319

1420
# Install AWS Plugin
1521
- include: aws.yml
1622
when: (elasticsearch_plugin_aws_version is defined)
23+
tags:
24+
- aws
25+
- plugins
1726

1827
# Install Other Generic Plugins
1928
- include: plugins.yml
2029
when: (elasticsearch_plugins is defined)
30+
tags:
31+
- plugins
2132

2233
# Install custom JARs
2334
- include: custom-jars.yml
2435
when: (elasticsearch_custom_jars is defined)
36+
tags:
37+
- java
38+
- custom-jars
2539

2640
# Install Marvel Plugin
2741
- include: marvel.yml
2842
when: (elasticsearch_plugin_marvel_version is defined)
43+
tags:
44+
- marvel
45+
- plugins
2946

3047
# Always run post-run tasks
3148
- include: post-run.yml

tasks/plugins.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
with_items: elasticsearch_plugins
3636
ignore_errors: yes
3737
- name: plugins | Installing Plugins
38-
shell: bin/plugin -install {{ item.name }} {{ '-url ' + item.url if item.url is defined else '' }}
38+
shell: bin/plugin install {{ item.name }} {{ '-url ' + item.url if item.url is defined else '' }}
3939
chdir={{ elasticsearch_home_dir }}
4040
when: item.download_only is not defined
4141
with_items: elasticsearch_plugins

tasks/spm.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# SPM Tasks (see http://sematext.com/spm/)
33

44
- name: spm | Install Collectd
5-
apt:
6-
pkg=collectd
7-
state=present
5+
action: >
6+
{{ansible_pkg_mgr}}
7+
pkg=collectd
8+
state=present
89
910
# TODO: Make idempotent
1011
- name: spm | Downloading and running package

tests/test1_var.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22

33
elasticsearch_version: 1.4.2
4-
elasticsearch_apt_java_package: oracle-java8-installer
4+
elasticsearch_java_package: oracle-java8-installer
55
elasticsearch_java_home: /usr/lib/jvm/java-8-oracle
66
elasticsearch_heap_size: 1g
77
elasticsearch_max_open_files: 65535

0 commit comments

Comments
 (0)