Skip to content

Commit 22de380

Browse files
authored
Merge pull request #48 from myii/PR_separate-formula-components
feat(pkg): separate components, use requisites and add `clean` states
2 parents c6fc98f + 007159a commit 22de380

16 files changed

+162
-56
lines changed

Diff for: README.rst

+33-4
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,51 @@ Available states
4848

4949
Meta-state (This is a state that includes other states)
5050

51-
This installs the template package, and starts the associated template service.
51+
This installs the template package,
52+
manages the template configuration file and then
53+
starts the associated template service.
5254

53-
``template.install``
55+
``template.package``
5456
--------------------
5557

5658
This state will install the template package only.
5759

5860
``template.config``
5961
-------------------
6062

61-
This state will configure the template service and has a depency on ``template.install``
63+
This state will configure the template service and has a dependency on ``template.install``
6264
via include list.
6365

6466
``template.service``
6567
--------------------
6668

67-
This state will start the template service and has a depency on ``template.config``
69+
This state will start the template service and has a dependency on ``template.config``
70+
via include list.
71+
72+
``template.clean``
73+
------------------
74+
75+
Meta-state (This is a state that includes other states)
76+
77+
this state will undo everything performed in the ``template`` meta-state in reverse order, i.e.
78+
stops the service,
79+
removes the configuration file and
80+
then uninstalls the package.
81+
82+
``template.service.clean``
83+
--------------------------
84+
85+
This state will stop the template service and disable it at boot time.
86+
87+
``template.config.clean``
88+
-------------------------
89+
90+
This state will remove the configuration of the template service and has a dependency on ``template.service.clean``
91+
via include list.
92+
93+
``template.package.clean``
94+
--------------------------
95+
96+
This state will remove the template package and has a depency on ``template.config.clean``
6897
via include list.
6998

Diff for: template/clean.sls

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .service.clean
6+
- .config.clean
7+
- .package.clean

Diff for: template/config.sls

-23
This file was deleted.

Diff for: template/config/clean.sls

+17
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_service_clean = tplroot ~ '.service.clean' %}
7+
{%- from tplroot ~ "/map.jinja" import template with context %}
8+
{%- from tplroot ~ "/macros.jinja" import files_switch with context %}
9+
10+
include:
11+
- {{ sls_service_clean }}
12+
13+
template-config-clean-file-absent:
14+
file.absent:
15+
- name: {{ template.config }}
16+
- require:
17+
- sls: {{ sls_service_clean }}

Diff for: template/config/file.sls

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 template with context %}
8+
{%- from tplroot ~ "/macros.jinja" import files_switch with context %}
9+
10+
include:
11+
- {{ sls_package_install }}
12+
13+
template-config-file-file-managed:
14+
file.managed:
15+
- name: {{ template.config }}
16+
- source: {{ files_switch(
17+
salt['config.get'](
18+
tplroot ~ ':tofs:files:template-config',
19+
['example.tmpl', 'example.tmpl.jinja']
20+
)
21+
) }}
22+
- mode: 644
23+
- user: root
24+
- group: root
25+
- template: jinja
26+
- require:
27+
- sls: {{ sls_package_install }}

Diff for: template/config/init.sls

+5
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

Diff for: template/init.sls

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# vim: ft=sls
33

44
include:
5-
- template.install
6-
- template.config
7-
- template.service
5+
- .package
6+
- .config
7+
- .service

Diff for: template/install.sls

-8
This file was deleted.

Diff for: template/map.jinja

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{#- Get the `topdir` from `tpldir` #}
5-
{%- set topdir = tpldir.split('/')[0] %}
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
66
{#- Start imports as #}
7-
{%- import_yaml topdir ~ "/defaults.yaml" or {} as default_settings %}
8-
{%- import_yaml topdir ~ "/osfamilymap.yaml" or {} as osfamilymap %}
9-
{%- import_yaml topdir ~ "/osmap.yaml" or {} as osmap %}
10-
{%- import_yaml topdir ~ "/osfingermap.yaml" or {} as osfingermap %}
7+
{%- import_yaml tplroot ~ "/defaults.yaml" or {} as default_settings %}
8+
{%- import_yaml tplroot ~ "/osfamilymap.yaml" or {} as osfamilymap %}
9+
{%- import_yaml tplroot ~ "/osmap.yaml" or {} as osmap %}
10+
{%- import_yaml tplroot ~ "/osfingermap.yaml" or {} as osfingermap %}
1111

1212
{% set defaults = salt['grains.filter_by'](default_settings,
1313
default='template',

Diff for: template/package/clean.sls

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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_clean = tplroot ~ '.config.clean' %}
7+
{%- from tplroot ~ "/map.jinja" import template with context %}
8+
9+
include:
10+
- {{ sls_config_clean }}
11+
12+
template-package-clean-pkg-removed:
13+
pkg.removed:
14+
- name: {{ template.pkg }}
15+
- require:
16+
- sls: {{ sls_config_clean }}

Diff for: template/package/init.sls

+5
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

Diff for: template/package/install.sls

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 template with context %}
7+
8+
template-package-install-pkg-installed:
9+
pkg.installed:
10+
- name: {{ template.pkg }}

Diff for: template/service.sls

-12
This file was deleted.

Diff for: template/service/clean.sls

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 template with context %}
7+
8+
template-service-clean-service-dead:
9+
service.dead:
10+
- name: {{ template.service.name }}
11+
- enable: False

Diff for: template/service/init.sls

+5
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

Diff for: template/service/running.sls

+17
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 template with context %}
8+
9+
include:
10+
- {{ sls_config_file }}
11+
12+
template-service-running-service-running:
13+
service.running:
14+
- name: {{ template.service.name }}
15+
- enable: True
16+
- require:
17+
- sls: {{ sls_config_file }}

0 commit comments

Comments
 (0)