From ba2bbe807f9b20ed16ab458720c1ba06a86160ab Mon Sep 17 00:00:00 2001 From: Paolo Smiraglia Date: Fri, 16 Jun 2017 19:26:28 +0200 Subject: [PATCH 1/5] Setup of testing with Travis and Kitchen --- .kitchen.yml | 35 +++++++++++++++++++++++++++++++++++ .travis.yml | 11 +++++++++++ Gemfile | 5 +++++ requirements.txt | 1 + 4 files changed, 52 insertions(+) create mode 100644 .kitchen.yml create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 requirements.txt diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..2b9d3fd --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,35 @@ +--- +driver: + name: docker + use_sudo: false + privileged: true + +provisioner: + name: salt_solo + formula: beats + salt_install: bootstrap + salt_bootstrap_options: -X stable + require_chef: false + state_top: + base: + "*": + - beats.repository + - beats.filebeat.install + - beats.filebeat.config + - beats.filebeat.purge + - beats.metricbeat.install + - beats.metricbeat.config + - 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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ffb8c67 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +sudo: required + +language: ruby + +services: + - docker + +before_install: + - pip install -r requirements.txt + +script: bundle exec kitchen verify diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1947ff4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "test-kitchen" +gem "kitchen-docker" +gem "kitchen-salt" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8ee609a --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +testinfra From c28c1855e8367c3d8eb9f94c6eddfe512c48875f Mon Sep 17 00:00:00 2001 From: Paolo Smiraglia Date: Mon, 19 Jun 2017 14:03:08 +0200 Subject: [PATCH 2/5] Added state to manage [File,Metric]beat service --- .kitchen.yml | 3 +++ README.rst | 14 ++++++++++++-- beats/filebeat/config.sls | 5 +++++ beats/filebeat/install.sls | 7 ------- beats/filebeat/service.sls | 16 ++++++++++++++++ beats/metricbeat/config.sls | 5 +++++ beats/metricbeat/install.sls | 7 ------- beats/metricbeat/service.sls | 16 ++++++++++++++++ 8 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 beats/filebeat/service.sls create mode 100644 beats/metricbeat/service.sls diff --git a/.kitchen.yml b/.kitchen.yml index 2b9d3fd..b62181f 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -9,6 +9,7 @@ provisioner: 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: @@ -16,9 +17,11 @@ provisioner: - 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 diff --git a/README.rst b/README.rst index 5242f5c..7b3a637 100644 --- a/README.rst +++ b/README.rst @@ -28,7 +28,12 @@ Installs the Filebeat package and enables the relative systemd unit. ``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`` ------------------------ @@ -43,7 +48,12 @@ Installs the Metricbeat package and enables the relative systemd unit. ``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`` -------------------------- diff --git a/beats/filebeat/config.sls b/beats/filebeat/config.sls index c1717c9..133874c 100644 --- a/beats/filebeat/config.sls +++ b/beats/filebeat/config.sls @@ -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 %} diff --git a/beats/filebeat/install.sls b/beats/filebeat/install.sls index 6f066ba..72af603 100644 --- a/beats/filebeat/install.sls +++ b/beats/filebeat/install.sls @@ -7,10 +7,3 @@ filebeat_install: - name: filebeat - require: - sls: beats.repository - -# Enable the filebeat systemd unit -filebeat_enabled: - service.enabled: - - name: filebeat - - require: - - pkg: filebeat_install diff --git a/beats/filebeat/service.sls b/beats/filebeat/service.sls new file mode 100644 index 0000000..82fdc83 --- /dev/null +++ b/beats/filebeat/service.sls @@ -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 %} diff --git a/beats/metricbeat/config.sls b/beats/metricbeat/config.sls index 22b114c..c6555a6 100644 --- a/beats/metricbeat/config.sls +++ b/beats/metricbeat/config.sls @@ -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 %} diff --git a/beats/metricbeat/install.sls b/beats/metricbeat/install.sls index d8bea78..a6e9589 100644 --- a/beats/metricbeat/install.sls +++ b/beats/metricbeat/install.sls @@ -7,10 +7,3 @@ metricbeat_install: - name: metricbeat - require: - sls: beats.repository - -# Enable the metricbeat systemd unit -metricbeat_enabled: - service.enabled: - - name: metricbeat - - require: - - pkg: metricbeat_install diff --git a/beats/metricbeat/service.sls b/beats/metricbeat/service.sls new file mode 100644 index 0000000..ad4c7dc --- /dev/null +++ b/beats/metricbeat/service.sls @@ -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 %} From 80366685b64aa51cfaa5b223f0359ee17c50f907 Mon Sep 17 00:00:00 2001 From: Paolo Smiraglia Date: Wed, 6 Sep 2017 10:30:20 +0200 Subject: [PATCH 3/5] Update readme file --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 7b3a637..01dd805 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ 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`` ------------------------- @@ -43,7 +43,7 @@ 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`` --------------------------- From 064319edeb95943d170758a505763a4d98300dd8 Mon Sep 17 00:00:00 2001 From: Paolo Smiraglia Date: Wed, 6 Sep 2017 10:30:46 +0200 Subject: [PATCH 4/5] Bump to version 0.0.3 --- CHANGELOG.rst | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b410c2d..c9b91b8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) diff --git a/VERSION b/VERSION index 4e379d2..bcab45a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.2 +0.0.3 From 278c9238f768c2f3ebce930c2236912481762b50 Mon Sep 17 00:00:00 2001 From: frussell Date: Fri, 23 Feb 2018 15:51:55 -0800 Subject: [PATCH 5/5] Adding Versioning, reflected in pillar.example --- beats/filebeat/install.sls | 1 + beats/metricbeat/install.sls | 1 + pillar.example | 2 ++ 3 files changed, 4 insertions(+) diff --git a/beats/filebeat/install.sls b/beats/filebeat/install.sls index 72af603..e9aa17e 100644 --- a/beats/filebeat/install.sls +++ b/beats/filebeat/install.sls @@ -5,5 +5,6 @@ include: filebeat_install: pkg.installed: - name: filebeat + - version: {{ salt['pillar.get']('beats:filebeat:version', '6.1.2') }} - require: - sls: beats.repository diff --git a/beats/metricbeat/install.sls b/beats/metricbeat/install.sls index a6e9589..8d13ffb 100644 --- a/beats/metricbeat/install.sls +++ b/beats/metricbeat/install.sls @@ -5,5 +5,6 @@ include: metricbeat_install: pkg.installed: - name: metricbeat + - version: {{ salt['pillar.get']('beats:metricbeat:version', '6.1.2') }} - require: - sls: beats.repository diff --git a/pillar.example b/pillar.example index eac9720..7bfd45e 100644 --- a/pillar.example +++ b/pillar.example @@ -1,5 +1,6 @@ beats: filebeat: + version: latest config: filebeat.prospectors: - input_type: log @@ -14,6 +15,7 @@ beats: rotateeverybytes: 10485760 keepfiles: 7 metricbeat: + version: latest config: cbeat.config.modules: path: ${path.config}/conf.d/*.yml