Skip to content

Added support for CentOS 7 and upgraded to install ES 2.x #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

elasticsearch_user: elasticsearch
elasticsearch_group: elasticsearch
elasticsearch_download_url: https://download.elasticsearch.org/elasticsearch/elasticsearch
elasticsearch_version: 1.7.3
elasticsearch_apt_repos:
- 'ppa:webupd8team/java'
elasticsearch_apt_java_package: oracle-java7-installer
elasticsearch_apt_dependencies:
- htop
- ntp
- unzip
elasticsearch_java_package: oracle-java7-installer
elasticsearch_pkg_dependencies:
- htop
- ntp
- unzip
elasticsearch_ubuntu_download_url: https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/{{elasticsearch_version}}/elasticsearch-{{elasticsearch_version}}.deb
elasticsearch_centos7_download_url: https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/{{elasticsearch_version}}/elasticsearch-{{elasticsearch_version}}.rpm
elasticsearch_max_open_files: 65535
elasticsearch_home_dir: /usr/share/elasticsearch
elasticsearch_plugin_dir: /usr/share/elasticsearch/plugins
Expand Down
5 changes: 4 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ galaxy_info:
author: "George Stathis"
company: Traackr
license: MIT
min_ansible_version: 1.3
min_ansible_version: 1.9
platforms:
- name: Ubuntu
versions:
- precise
- name: EL
versions:
- 7
categories:
- database:nosql
dependencies: []
5 changes: 3 additions & 2 deletions tasks/custom-jars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
# - ...

# Loop though elasticsearch_custom_jars and install them
- name: Installing Custom JARs
- name: custom jars | Installing Custom JARs
action: >
get_url url={{ item.uri }}
url_username={{ item.user }} url_password={{ item.passwd }} dest="{{ elasticsearch_home_dir }}/lib/{{ item.filename }}"
with_items: elasticsearch_custom_jars
# Fix permissions
- file: >
- name: custom jars |
file: >
path="{{ elasticsearch_home_dir }}/lib" state=directory
owner={{ elasticsearch_user }} group={{ elasticsearch_group }}
recurse=yes
62 changes: 48 additions & 14 deletions tasks/elastic-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
state=present
update_cache=yes
cache_valid_time={{apt_cache_valid_time}}
when: ansible_distribution == "Ubuntu"

- name: elastic-install | Install dependencies
apt:
pkg={{ item }}
state=present
with_items: elasticsearch_apt_dependencies
action: >
{{ ansible_pkg_mgr }}
name={{ item }}
state=present
with_items: "{{ elasticsearch_pkg_dependencies }}"

- name: elastic-install | Configuring elastic group
group:
Expand Down Expand Up @@ -45,14 +47,26 @@

- name: elastic-install | Download Elasticsearch deb
get_url:
url={{ elasticsearch_download_url }}/elasticsearch-{{ elasticsearch_version }}.deb
dest=/tmp/elasticsearch-{{ elasticsearch_version }}.deb
url={{ elasticsearch_ubuntu_download_url }}
dest=/tmp/
mode=0440
when: not installed_version.stat.exists
register: downloaded_pkg
when: not installed_version.stat.exists and
ansible_distribution == "Ubuntu"

- name: elastic-install | Download Elasticsearch rpm
get_url:
url={{ elasticsearch_centos7_download_url }}
dest=/tmp/
mode=0440
register: downloaded_pkg
when: not installed_version.stat.exists and
ansible_distribution == "CentOS" and
ansible_distribution_major_version == "7"

#shell: dpkg --remove elasticsearch
- name: elastic-install | Uninstalling previous version if applicable
apt:
action: >
{{ ansible_pkg_mgr }}
name="elasticsearch"
state="absent"
when: not installed_version.stat.exists
Expand All @@ -63,9 +77,17 @@
state=absent
when: not installed_version.stat.exists

- name: elastic-install | Install Elasticsearch deb
shell: dpkg -i -E --force-confnew /tmp/elasticsearch-{{ elasticsearch_version }}.deb
when: not installed_version.stat.exists
- name: elastic-install | Ubuntu | Install Elasticsearch deb
shell: dpkg -i -E --force-confnew {{ downloaded_pkg.dest }}
when: not installed_version.stat.exists and
ansible_distribution == "Ubuntu"
notify: Restart Elasticsearch

- name: elastic-install | CentOS-7 | Install Elasticsearch rpm
shell: rpm -i {{ downloaded_pkg.dest }}
when: not installed_version.stat.exists and
ansible_distribution == "CentOS" and
ansible_distribution_major_version == "7"
notify: Restart Elasticsearch

- name: elastic-install | Ensure elastic directories exists
Expand All @@ -83,7 +105,7 @@
- "{{ elasticsearch_work_dir }}"
- "{{ elasticsearch_conf_dir }}"

- name: Configure limits max_open_files
- name: elastic-install | Configure limits max_open_files
lineinfile:
dest=/etc/security/limits.conf
regexp='^{{ elasticsearch_user }} - nofile {{ elasticsearch_max_open_files }}'
Expand Down Expand Up @@ -116,6 +138,7 @@
insertafter=EOF
line='session required pam_limits.so'
notify: Restart Elasticsearch
when: ansible_distribution == "Ubuntu"

- name: elastic-install | Configure common-session-noninteractive pam_limits.so
lineinfile:
Expand All @@ -124,6 +147,17 @@
insertafter=EOF
line='session required pam_limits.so'
notify: Restart Elasticsearch
when: ansible_distribution == "Ubuntu"

- name: elastic-install | Configure system-auth pam_limits.so
lineinfile:
dest=/etc/pam.d/system-auth
regexp='^session required pam_limits.so'
insertafter=EOF
line='session required pam_limits.so'
notify: Restart Elasticsearch
when: ansible_distribution == "CentOS" and
ansible_distribution_major_version == "7"

- name: elastic-install | Configure sudo pam_limits.so
lineinfile:
Expand Down Expand Up @@ -158,4 +192,4 @@
owner={{ elasticsearch_user }}
group={{ elasticsearch_group }}
mode=0644
notify: Restart Elasticsearch
notify: Restart Elasticsearch
7 changes: 5 additions & 2 deletions tasks/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
- name: java | Accept Oracle license prior JDK installation
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
creates=/usr/lib/jvm/java-8-oracle
when: ansible_distribution == "Ubuntu"

- name: java | Update repositories
apt_repository:
repo={{ item }}
state=present
update_cache=yes
with_items: elasticsearch_apt_repos
when: ansible_distribution == "Ubuntu"

- name: java | Install dependencies
apt:
pkg={{elasticsearch_apt_java_package}}
action: >
{{ansible_pkg_mgr}}
name={{elasticsearch_java_package}}
state=present
17 changes: 17 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,45 @@
# Install Java
- include: java.yml
when: elasticsearch_install_java
tags:
- java

# Configure timezome
- include: timezone.yml
tags:
- timezone

# Install and configure elasticsearch
- include: elastic-install.yml
tags:
- install

# Install AWS Plugin
- include: aws.yml
when: (elasticsearch_plugin_aws_version is defined)
tags:
- aws
- plugins

# Install Other Generic Plugins
- include: plugins.yml
when: (elasticsearch_plugins is defined)
tags:
- plugins

# Install custom JARs
- include: custom-jars.yml
when: (elasticsearch_custom_jars is defined)
tags:
- java
- custom-jars

# Install Marvel Plugin
- include: marvel.yml
when: (elasticsearch_plugin_marvel_version is defined)
tags:
- marvel
- plugins

# Always run post-run tasks
- include: post-run.yml
2 changes: 1 addition & 1 deletion tasks/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
with_items: elasticsearch_plugins
ignore_errors: yes
- name: plugins | Installing Plugins
shell: bin/plugin -install {{ item.name }} {{ '-url ' + item.url if item.url is defined else '' }}
shell: bin/plugin install {{ item.name }} {{ '-url ' + item.url if item.url is defined else '' }}
chdir={{ elasticsearch_home_dir }}
when: item.download_only is not defined
with_items: elasticsearch_plugins
Expand Down
7 changes: 4 additions & 3 deletions tasks/spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# SPM Tasks (see http://sematext.com/spm/)

- name: spm | Install Collectd
apt:
pkg=collectd
state=present
action: >
{{ansible_pkg_mgr}}
pkg=collectd
state=present

# TODO: Make idempotent
- name: spm | Downloading and running package
Expand Down
2 changes: 1 addition & 1 deletion tests/test1_var.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

elasticsearch_version: 1.4.2
elasticsearch_apt_java_package: oracle-java8-installer
elasticsearch_java_package: oracle-java8-installer
elasticsearch_java_home: /usr/lib/jvm/java-8-oracle
elasticsearch_heap_size: 1g
elasticsearch_max_open_files: 65535
Expand Down