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

added curator to this formula #47

Open
wants to merge 2 commits 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
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_PATH: "vendor/bundle"
43 changes: 11 additions & 32 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,28 @@ provisioner:
- sun-java
- sun-java.env
- elasticsearch
pillars:
top.sls:
base:
"*":
- elasticsearch

platforms:
- name: ubuntu-14.04
driver_config:
provision_command:
- locale-gen en_US.UTF-8
- name: ubuntu-16.04
driver_config:
provision_command:
- apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8
run_command: /sbin/init

suites:
- name: default
- name: with-pillar-set
- name: elasticsearch_server
provisioner:
pillars:
top.sls:
base:
'*':
- elasticsearch
elasticsearch.sls:
elasticsearch:
config:
network.host: 0.0.0.0
plugins:
lang-python: lang-python
- name: version-5.0
excludes:
- ubuntu-14.04
pillars-from-files:
elasticsearch.sls: test/pillar/elasticsearch.sls
- name: elasticsearch_server_curator
provisioner:
pillars:
top.sls:
base:
'*':
- elasticsearch
elasticsearch.sls:
elasticsearch:
version: 5.*
plugins:
lang-python: lang-python
jvm_opts:
- '# Test String'
pillars-from-files:
elasticsearch.sls: test/pillar/curator.sls

verifier:
name: shell
Expand Down
51 changes: 51 additions & 0 deletions elasticsearch/curator.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{%- from "elasticsearch/map.jinja" import elasticsearch_map with context %}

include:
- elasticsearch.pkg

elasticsearch_curator_packages:
pkg.installed:
- names: {{ elasticsearch_map.curator.curator_pkgs }}

elasticsearch_curator_config:
file.managed:
- name: /etc/elasticsearch/curator.yml
- source: salt://elasticsearch/files/curator.yml
- group: elasticsearch
- mode: 640
- template: jinja
- require:
- pkg: elasticsearch_pkg

elasticsearch_curator_action_config:
file.managed:
- name: /etc/elasticsearch/curator_actions.yml
- source: salt://elasticsearch/files/curator_actions.yml
- group: elasticsearch
- mode: 640
- template: jinja
- require:
- file: elasticsearch_curator_config

elasticsearch_curator_cron:
cron.present:
- name: "curator --config /etc/elasticsearch/curator.yml /etc/elasticsearch/curator_actions.yml >/dev/null"
- user: elasticsearch
- minute: random
- hour: 1

elasticsearch_curator_cron_path:
cron.env_present:
- name: PATH
- user: elasticsearch
- value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- require_in:
- cron: elasticsearch_curator_cron

{%- if elasticsearch_map.curator.logfile|default("") %}
elasticsearch_curator_log:
file.managed:
- name: {{ elasticsearch_map.curator.logfile }}
- user: elasticsearch
- group: elasticsearch
{%- endif %}
25 changes: 25 additions & 0 deletions elasticsearch/files/curator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{%- from "elasticsearch/map.jinja" import elasticsearch_map with context -%}
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- {% if elasticsearch_map.config['network.host'] == '0.0.0.0' %}127.0.0.1{% else %}{{ elasticsearch_map.config['network.host'] }}{% endif %}
port: {{ elasticsearch_map.config['http.port'] }}
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
aws_key:
aws_secret_key:
aws_region:
ssl_no_validate: False
http_auth:
timeout: {{ elasticsearch_map.curator.timeout|default(120) }}
master_only: {{ elasticsearch_map.curator.get('master_only', False)|lower }}

logging:
loglevel: {{ elasticsearch_map.curator.loglevel|default("INFO") }}
logfile: {{ elasticsearch_map.curator.logfile|default("") }}
logformat: {{ elasticsearch_map.curator.logformat|default("default") }}
7 changes: 7 additions & 0 deletions elasticsearch/files/curator_actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{%- from "elasticsearch/map.jinja" import elasticsearch_map with context -%}
---
actions:
{%- for action in elasticsearch_map.curator.actions %}
{{ loop.index }}:
{{ action|yaml }}
{%- endfor %}
6 changes: 6 additions & 0 deletions elasticsearch/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% from "elasticsearch/map.jinja" import elasticsearch_map with context %}
{% from "elasticsearch/settings.sls" import elasticsearch with context %}

include:
- elasticsearch.repo
- elasticsearch.pkg
Expand All @@ -6,3 +9,6 @@ include:
- elasticsearch.jvmopts
- elasticsearch.service
- elasticsearch.plugins
{%- if elasticsearch_map.curator is defined %}
- elasticsearch.curator
{%- endif %}
5 changes: 4 additions & 1 deletion elasticsearch/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
'default': {
'pkg': 'elasticsearch',
},
'Ubuntu': {
'pkg': 'elasticsearch',
},
},
merge=salt['pillar.get']('elasticsearch:lookup', {}),
merge=salt['pillar.get']('elasticsearch', {}),
default='default')
%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import testinfra


def test_service_is_running_and_enabled(Service):
elasticsearch = Service('elasticsearch')
assert elasticsearch.is_running
assert elasticsearch.is_enabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import testinfra


def test_service_is_running_and_enabled(Service):
elasticsearch = Service('elasticsearch')
assert elasticsearch.is_running
assert elasticsearch.is_enabled
40 changes: 40 additions & 0 deletions test/pillar/curator.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
elasticsearch:
version: 5.6.3
config:
cluster.name: escaleinfra
node.name: node1
path.data: /srv/data
path.logs: /srv/logs
network.host: 0.0.0.0
http.port: 9200
sysconfig:
ES_STARTUP_SLEEP_TIME: 5
MAX_OPEN_FILES: 65535
curator:
curator_pkgs:
- python-elasticsearch-curator
- cron
timeout: 900
logfile: /var/log/elasticsearch/curator.log
logformat: json
master_only: true
actions:
- action: delete_indices
description: >-
Delete indices older than 7 days (based on index name).
Ignore the error if the filter does not result in an actionable
list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
continue_if_exception: False
disable_action: False
filters:
- filtertype: pattern
kind: regex
value: '.*\-\d\d\d\d\.\d\d\.\d\d$'
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 7
12 changes: 12 additions & 0 deletions test/pillar/elasticsearch.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
elasticsearch:
version: 5.6.3
config:
cluster.name: escaleinfra
node.name: node1
path.data: /srv/data
path.logs: /srv/logs
network.host: 0.0.0.0
http.port: 9200
sysconfig:
ES_STARTUP_SLEEP_TIME: 5
MAX_OPEN_FILES: 65535