Skip to content
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

repo change via major_version #13

Merged
merged 3 commits into from
Nov 14, 2016
Merged
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
17 changes: 17 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ suites:
elasticsearch:
config:
network.host: 0.0.0.0
- name: version-5.0
driver_config:
provision_command:
- apt-get update # base image is out of date
- apt-get install -y software-properties-common # required for add-apt-repository
- add-apt-repository -y ppa:openjdk-r/ppa
- apt-get update
- apt-get install -y openjdk-8-jre-headless
provisioner:
pillars:
top.sls:
base:
'*':
- elasticsearch
elasticsearch.sls:
elasticsearch:
major_version: 5

verifier:
name: shell
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Elasticsearch
=============

Formula to install and configure Elasticsearch.
Formula to install and configure Elasticsearch. Supports 2.x and 5.x.


.. note::
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/pkg.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{%- set major_version = salt['pillar.get']('elasticsearch:major_version', 2) %}

include:
- elasticsearch.repo

Expand All @@ -6,5 +8,6 @@ include:
elasticsearch_pkg:
pkg.installed:
- name: {{ elasticsearch.pkg }}
- version: {{ major_version }}.*
- require:
- sls: elasticsearch.repo
35 changes: 28 additions & 7 deletions elasticsearch/repo.sls
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
{%- set major_version = salt['pillar.get']('elasticsearch:major_version', 2) %}

{%- if major_version == 5 %}
{%- set repo_url = 'https://artifacts.elastic.co/packages/5.x' %}
{%- else %}
{%- set repo_url = 'http://packages.elastic.co/elasticsearch/2.x' %}
{%- endif %}

{%- if major_version == 5 %}
apt-transport-https:
pkg.installed
{%- endif %}

elasticsearch_repo:
pkgrepo.managed:
- humanname: Elasticsearch 2.
{% if grains.get('os_family') == 'Debian' %}
- name: deb http://packages.elastic.co/elasticsearch/2.x/debian stable main
- humanname: Elasticsearch {{ major_version }}
{%- if grains.get('os_family') == 'Debian' %}
{%- if major_version == 5 %}
- name: deb {{ repo_url }}/apt stable main
{%- else %}
- name: deb {{ repo_url }}/debian stable main
{%- endif %}
- dist: stable
- file: /etc/apt/sources.list.d/elasticsearch.list
- keyid: D88E42B4
- keyserver: keyserver.ubuntu.com
- clean_file: true
{% elif grains['os_family'] == 'RedHat' %}
{%- elif grains['os_family'] == 'RedHat' %}
- name: elasticsearch
- baseurl: http://packages.elastic.co/elasticsearch/2.x/centos
{%- if major_version == 5 %}
- baseurl: {{ repo_url }}/centos
{%- else %}
- baseurl: {{ repo_url }}/centos
{%- endif %}
- enabled: 1
- gpgcheck: 1
- gpgkey: http://packages.elastic.co/GPG-KEY-elasticsearch
{% endif %}
- gpgkey: http://artifacts.elastic.co/GPG-KEY-elasticsearch
{%- endif %}
2 changes: 1 addition & 1 deletion elasticsearch/service.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ elasticsearch_service:
- file: elasticsearch_cfg
{%- endif %}
- require:
- sls: elasticsearch.pkg
- pkg: elasticsearch
1 change: 1 addition & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
elasticsearch:
major_version: 2
config:
cluster.name: my-application
node.name: node2
Expand Down
12 changes: 12 additions & 0 deletions test/integration/version-5.0/testinfra/test_elasticsearch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import testinfra


def test_package_in_installed(Package):
elasticsearch = Package('elasticsearch')
assert elasticsearch.is_installed
assert elasticsearch.version.startswith('5.0')

def test_service_is_running_and_enabled(Service):
elasticsearch = Service('elasticsearch')
assert elasticsearch.is_running
assert elasticsearch.is_enabled