Bladeren bron

refactor(states): switch to the new directory layout

tags/v0.4.0
Nicolas Rodriguez 5 jaren geleden
bovenliggende
commit
7ea12e391e
12 gewijzigde bestanden met toevoegingen van 104 en 56 verwijderingen
  1. +17
    -13
      docs/README.rst
  2. +1
    -1
      kitchen.yml
  3. +0
    -15
      syslog_ng/config.sls
  4. +23
    -0
      syslog_ng/config/file.sls
  5. +5
    -0
      syslog_ng/config/init.sls
  6. +6
    -2
      syslog_ng/files/syslog-ng.conf
  7. +6
    -10
      syslog_ng/init.sls
  8. +5
    -0
      syslog_ng/package/init.sls
  9. +19
    -0
      syslog_ng/package/install.sls
  10. +0
    -15
      syslog_ng/packages.sls
  11. +5
    -0
      syslog_ng/service/init.sls
  12. +17
    -0
      syslog_ng/service/running.sls

+ 17
- 13
docs/README.rst Bestand weergeven

@@ -49,7 +49,7 @@ Available states
^^^^^^^^^^^^^
Installs and configures the syslog_ng package.

``syslog_ng.packages``
``syslog_ng.package``
^^^^^^^^^^^^^^^^^^^^^^
Installs the syslog_ng package and optional packages which may provide additional functionalities.

@@ -57,6 +57,10 @@ Installs the syslog_ng package and optional packages which may provide additiona
^^^^^^^^^^^^^^^^^^^^
This state manages the file ``syslog_ng.conf`` under ``/etc/syslog-ng`` (template found in "syslog_ng/files"). The configuration is populated by values in "syslog_ng/map.jinja" based on the package's default values (and RedHat, Debian, Suse and Arch family distribution specific values), which can then be overridden by values of the same name in pillar.

``syslog_ng.service``
^^^^^^^^^^^^^^^^^^^^
Manages the startup and running state of the syslog_ng service.

Testing
-------

@@ -72,32 +76,32 @@ Requirements

$ gem install bundler
$ bundle install
$ bundle exec kitchen test [platform]
$ bin/kitchen test [platform]

Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
e.g. ``debian-9-2019-2-py3``.

``kitchen converge``
^^^^^^^^^^^^^^^^^^^^
``bin/kitchen converge``
^^^^^^^^^^^^^^^^^^^^^^^^

Creates the docker instance and runs the ``template`` main state, ready for testing.
Creates the docker instance and runs the ``syslog_ng`` main state, ready for testing.

``kitchen verify``
^^^^^^^^^^^^^^^^^^
``bin/kitchen verify``
^^^^^^^^^^^^^^^^^^^^^^

Runs the ``inspec`` tests on the actual instance.

``kitchen destroy``
^^^^^^^^^^^^^^^^^^^
``bin/kitchen destroy``
^^^^^^^^^^^^^^^^^^^^^^^

Removes the docker instance.

``kitchen test``
^^^^^^^^^^^^^^^^
``bin/kitchen test``
^^^^^^^^^^^^^^^^^^^^

Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.

``kitchen login``
^^^^^^^^^^^^^^^^^
``bin/kitchen login``
^^^^^^^^^^^^^^^^^^^^^

Gives you SSH access to the instance for manual testing.

+ 1
- 1
kitchen.yml Bestand weergeven

@@ -154,7 +154,7 @@ suites:
state_top:
base:
'*':
- syslog_ng.config
- syslog_ng
pillars:
top.sls:
base:

+ 0
- 15
syslog_ng/config.sls Bestand weergeven

@@ -1,15 +0,0 @@
{% from "syslog_ng/map.jinja" import syslog_ng with context %}

include:
- syslog_ng

syslog_ng.conf:
file.managed:
- name: {{ syslog_ng.syslog_ng_config }}
- source: {{ syslog_ng.syslog_ng_config_src }}
- template: jinja
- user: root
- group: root
- mode: 644
- watch_in:
- service: syslog_ng

+ 23
- 0
syslog_ng/config/file.sls Bestand weergeven

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}

include:
- {{ sls_package_install }}

syslog_ng/config/install:
file.managed:
- name: {{ syslog_ng.syslog_ng_config }}
- source: {{ syslog_ng.syslog_ng_config_src }}
- template: jinja
- user: root
- group: root
- mode: 644
- require:
- sls: {{ sls_package_install }}
- context:
syslog_ng: {{ syslog_ng | json }}

+ 5
- 0
syslog_ng/config/init.sls Bestand weergeven

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .file

+ 6
- 2
syslog_ng/files/syslog-ng.conf Bestand weergeven

@@ -1,5 +1,9 @@
{%- from "syslog_ng/macro.jinja" import rule_builder -%}
{%- from "syslog_ng/map.jinja" import syslog_ng with context -%}
########################################################################
# File managed by Salt at <{{ source }}>.
# Your changes will be overwritten.
########################################################################

{%- from "syslog_ng/macro.jinja" import rule_builder %}

@version: {{ syslog_ng.get('version', '3.3') }}


+ 6
- 10
syslog_ng/init.sls Bestand weergeven

@@ -1,11 +1,7 @@
{% from "syslog_ng/map.jinja" import syslog_ng with context %}
# -*- coding: utf-8 -*-
# vim: ft=sls

syslog_ng:
pkg.installed:
- name: {{ syslog_ng.package }}

service.running:
- enable: True
- name: {{ syslog_ng.service }}
- watch:
- pkg: syslog_ng
include:
- .package
- .config
- .service

+ 5
- 0
syslog_ng/package/init.sls Bestand weergeven

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .install

+ 19
- 0
syslog_ng/package/install.sls Bestand weergeven

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}

syslog_ng/package/install:
pkg.installed:
- name: {{ syslog_ng.package }}

{%- if syslog_ng.packages is defined and syslog_ng.packages %}
syslog_ng/packages/install:
pkg.installed:
- pkgs:
{%- for pkg in syslog_ng.packages %}
- {{ pkg.name }}{% if pkg.version is defined and pkg.version %}: '{{ pkg.version }}' {% endif %}
{%- endfor %}
{%- endif %}

+ 0
- 15
syslog_ng/packages.sls Bestand weergeven

@@ -1,15 +0,0 @@
{% from "syslog_ng/map.jinja" import syslog_ng with context %}

include:
- syslog_ng

{%- if syslog_ng.packages is defined and syslog_ng.packages %}
syslog_ng_packages:
pkg.installed:
- pkgs:
{%- for pkg in syslog_ng.packages %}
- {{ pkg.name }}{% if pkg.version is defined and pkg.version %}: '{{ pkg.version }}' {% endif %}
{%- endfor %}
- watch_in:
- service: syslog_ng
{%- endif %}

+ 5
- 0
syslog_ng/service/init.sls Bestand weergeven

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .running

+ 17
- 0
syslog_ng/service/running.sls Bestand weergeven

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}

include:
- {{ sls_config_file }}

syslog_ng/service/running:
service.running:
- name: {{ syslog_ng.service }}
- enable: true
- require:
- sls: {{ sls_config_file }}

Laden…
Annuleren
Opslaan