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

Adding Versioning, reflected in pillar.example #3

Open
wants to merge 7 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
38 changes: 38 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
driver:
name: docker
use_sudo: false
privileged: true

provisioner:
name: salt_solo
formula: beats
salt_install: bootstrap
salt_bootstrap_options: -X stable
salt_bootstrap_url: https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh
require_chef: false
state_top:
base:
"*":
- beats.repository
- beats.filebeat.install
- beats.filebeat.config
- beats.filebeat.service
- beats.filebeat.purge
- beats.metricbeat.install
- beats.metricbeat.config
- beats.metricbeat.service
- beats.metricbeat.purge
- beats.purge

platforms:
- name: debian-jessie
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: centos-6
- name: centos-7
driver_config:
run_command: /usr/lib/systemd/systemd

suites:
- name: default
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo: required

language: ruby

services:
- docker

before_install:
- pip install -r requirements.txt

script: bundle exec kitchen verify
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
beats-formula
=============

0.0.3 (2017-09-06)

- State to manage [File, Metric]beat daemon (c28c185)
- Testing with Travis/Kitchen (ba2bbe8)

0.0.2 (2017-06-14)

- Added Metricbeat configuration state (8eb5ce9)
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "test-kitchen"
gem "kitchen-docker"
gem "kitchen-salt"
18 changes: 14 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ Installs the Elastic repository for version 5.x packages.
``beats.filebeat.install``
--------------------------

Installs the Filebeat package and enables the relative systemd unit.
Installs the Filebeat package.

``beats.filebeat.config``
-------------------------

Configure Filebeat by reading from ``beats:filebeat:config`` pillar key.
Configures Filebeat by reading from ``beats:filebeat:config`` pillar key.

``beats.filebeat.service``
--------------------------

Runs and enables the Filebeat service.

``beats.filebeat.purge``
------------------------
Expand All @@ -38,12 +43,17 @@ Purges the environment created by ``beats.filebeat.*`` states.
``beats.metricbeat.install``
----------------------------

Installs the Metricbeat package and enables the relative systemd unit.
Installs the Metricbeat package.

``beats.metricbeat.config``
---------------------------

Configure Metricbeat by reading from ``beats:metricbeat:config`` pillar key.
Configures Metricbeat by reading from ``beats:metricbeat:config`` pillar key.

``beats.metricbeat.service``
----------------------------

Runs and enables the Metricbeat service.

``beats.metricbeat.purge``
--------------------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2
0.0.3
5 changes: 5 additions & 0 deletions beats/filebeat/config.sls
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
include:
- beats.filebeat.install

{% if salt['pillar.get']('beats:filebeat:config', {}) %}
/etc/filebeat/filebeat.yml:
file.serialize:
- dataset_pillar: 'beats:filebeat:config'
- formatter: yaml
- require:
- sls: beats.filebeat.install
{% endif %}
8 changes: 1 addition & 7 deletions beats/filebeat/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ include:
filebeat_install:
pkg.installed:
- name: filebeat
- version: {{ salt['pillar.get']('beats:filebeat:version', '6.1.2') }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not something like that?

[...]
{% if beats.filebeat.version is defined %}
- version: {{ salt['pillar.get']('beats:filebeat:version') }}
{% endif %}
[...]

If specified within the pillar, the version will be enforced. If not, the latest version of the package will be installed

- require:
- sls: beats.repository

# Enable the filebeat systemd unit
filebeat_enabled:
service.enabled:
- name: filebeat
- require:
- pkg: filebeat_install
16 changes: 16 additions & 0 deletions beats/filebeat/service.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include:
- beats.filebeat.install
- beats.filebeat.config

# Enable and run Filebeat daemon
filebeat_running:
service.running:
- name: filebeat
enable: True
require:
- sls: beats.filebeat.install
{%- if salt['pillar.get']('beats:filebeat:config') %}
- sls: beats.filebeat.config
watch:
- file: /etc/filebeat/filebeat.yml
{% endif %}
5 changes: 5 additions & 0 deletions beats/metricbeat/config.sls
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
include:
- beats.metricbeat.install

{% if salt['pillar.get']('beats:metricbeat:config', {}) %}
/etc/metricbeat/metricbeat.yml:
file.serialize:
- dataset_pillar: 'beats:metricbeat:config'
- formatter: yaml
- require:
- sls: beats.metricbeat.install
{% endif %}
8 changes: 1 addition & 7 deletions beats/metricbeat/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ include:
metricbeat_install:
pkg.installed:
- name: metricbeat
- version: {{ salt['pillar.get']('beats:metricbeat:version', '6.1.2') }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not something like that?

[...]
{% if beats.metricbeat.version is defined %}
- version: {{ salt['pillar.get']('beats:metricbeat:version') }}
{% endif %}
[...]

If specified within the pillar, the version will be enforced. If not, the latest version of the package will be installed

- require:
- sls: beats.repository

# Enable the metricbeat systemd unit
metricbeat_enabled:
service.enabled:
- name: metricbeat
- require:
- pkg: metricbeat_install
16 changes: 16 additions & 0 deletions beats/metricbeat/service.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include:
- beats.metricbeat.install
- beats.metricbeat.config

# Enable and run Metricbeat daemon
metricbeat_running:
service.running:
- name: metricbeat
enable: True
require:
- sls: beats.metricbeat.install
{%- if salt['pillar.get']('beats:metricbeat:config') %}
- sls: beats.metricbeat.config
watch:
- file: /etc/metricbeat/metricbeat.yml
{% endif %}
2 changes: 2 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
beats:
filebeat:
version: latest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using latest as version could break pkg.installed state.

config:
filebeat.prospectors:
- input_type: log
Expand All @@ -14,6 +15,7 @@ beats:
rotateeverybytes: 10485760
keepfiles: 7
metricbeat:
version: latest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using latest as version could break pkg.installed state.

config:
cbeat.config.modules:
path: ${path.config}/conf.d/*.yml
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testinfra