Skip to content

Commit 7ea12e3

Browse files
committed
refactor(states): switch to the new directory layout
1 parent c027735 commit 7ea12e3

File tree

12 files changed

+104
-56
lines changed

12 files changed

+104
-56
lines changed

docs/README.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ Available states
4949
^^^^^^^^^^^^^
5050
Installs and configures the syslog_ng package.
5151

52-
``syslog_ng.packages``
52+
``syslog_ng.package``
5353
^^^^^^^^^^^^^^^^^^^^^^
5454
Installs the syslog_ng package and optional packages which may provide additional functionalities.
5555

5656
``syslog_ng.config``
5757
^^^^^^^^^^^^^^^^^^^^
5858
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.
5959

60+
``syslog_ng.service``
61+
^^^^^^^^^^^^^^^^^^^^
62+
Manages the startup and running state of the syslog_ng service.
63+
6064
Testing
6165
-------
6266

@@ -72,32 +76,32 @@ Requirements
7276
7377
$ gem install bundler
7478
$ bundle install
75-
$ bundle exec kitchen test [platform]
79+
$ bin/kitchen test [platform]
7680
7781
Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
7882
e.g. ``debian-9-2019-2-py3``.
7983

80-
``kitchen converge``
81-
^^^^^^^^^^^^^^^^^^^^
84+
``bin/kitchen converge``
85+
^^^^^^^^^^^^^^^^^^^^^^^^
8286

83-
Creates the docker instance and runs the ``template`` main state, ready for testing.
87+
Creates the docker instance and runs the ``syslog_ng`` main state, ready for testing.
8488

85-
``kitchen verify``
86-
^^^^^^^^^^^^^^^^^^
89+
``bin/kitchen verify``
90+
^^^^^^^^^^^^^^^^^^^^^^
8791

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

90-
``kitchen destroy``
91-
^^^^^^^^^^^^^^^^^^^
94+
``bin/kitchen destroy``
95+
^^^^^^^^^^^^^^^^^^^^^^^
9296

9397
Removes the docker instance.
9498

95-
``kitchen test``
96-
^^^^^^^^^^^^^^^^
99+
``bin/kitchen test``
100+
^^^^^^^^^^^^^^^^^^^^
97101

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

100-
``kitchen login``
101-
^^^^^^^^^^^^^^^^^
104+
``bin/kitchen login``
105+
^^^^^^^^^^^^^^^^^^^^^
102106

103107
Gives you SSH access to the instance for manual testing.

kitchen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ suites:
154154
state_top:
155155
base:
156156
'*':
157-
- syslog_ng.config
157+
- syslog_ng
158158
pillars:
159159
top.sls:
160160
base:

syslog_ng/config.sls

Lines changed: 0 additions & 15 deletions
This file was deleted.

syslog_ng/config/file.sls

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- set sls_package_install = tplroot ~ '.package.install' %}
7+
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}
8+
9+
include:
10+
- {{ sls_package_install }}
11+
12+
syslog_ng/config/install:
13+
file.managed:
14+
- name: {{ syslog_ng.syslog_ng_config }}
15+
- source: {{ syslog_ng.syslog_ng_config_src }}
16+
- template: jinja
17+
- user: root
18+
- group: root
19+
- mode: 644
20+
- require:
21+
- sls: {{ sls_package_install }}
22+
- context:
23+
syslog_ng: {{ syslog_ng | json }}

syslog_ng/config/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .file

syslog_ng/files/syslog-ng.conf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
{%- from "syslog_ng/macro.jinja" import rule_builder -%}
2-
{%- from "syslog_ng/map.jinja" import syslog_ng with context -%}
1+
########################################################################
2+
# File managed by Salt at <{{ source }}>.
3+
# Your changes will be overwritten.
4+
########################################################################
5+
6+
{%- from "syslog_ng/macro.jinja" import rule_builder %}
37

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

syslog_ng/init.sls

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
{% from "syslog_ng/map.jinja" import syslog_ng with context %}
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
23

3-
syslog_ng:
4-
pkg.installed:
5-
- name: {{ syslog_ng.package }}
6-
7-
service.running:
8-
- enable: True
9-
- name: {{ syslog_ng.service }}
10-
- watch:
11-
- pkg: syslog_ng
4+
include:
5+
- .package
6+
- .config
7+
- .service

syslog_ng/package/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .install

syslog_ng/package/install.sls

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}
7+
8+
syslog_ng/package/install:
9+
pkg.installed:
10+
- name: {{ syslog_ng.package }}
11+
12+
{%- if syslog_ng.packages is defined and syslog_ng.packages %}
13+
syslog_ng/packages/install:
14+
pkg.installed:
15+
- pkgs:
16+
{%- for pkg in syslog_ng.packages %}
17+
- {{ pkg.name }}{% if pkg.version is defined and pkg.version %}: '{{ pkg.version }}' {% endif %}
18+
{%- endfor %}
19+
{%- endif %}

syslog_ng/packages.sls

Lines changed: 0 additions & 15 deletions
This file was deleted.

syslog_ng/service/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .running

syslog_ng/service/running.sls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- set sls_config_file = tplroot ~ '.config.file' %}
7+
{%- from tplroot ~ "/map.jinja" import syslog_ng with context %}
8+
9+
include:
10+
- {{ sls_config_file }}
11+
12+
syslog_ng/service/running:
13+
service.running:
14+
- name: {{ syslog_ng.service }}
15+
- enable: true
16+
- require:
17+
- sls: {{ sls_config_file }}

0 commit comments

Comments
 (0)