From c21f82b8856c88a0f40cadb8681c51b300f4a8cc Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 24 Feb 2019 04:37:11 +0000 Subject: [PATCH 01/13] refactor(pkg): move `pkg` related components into separate directory --- template/init.sls | 4 +--- template/{ => pkg}/config.sls | 6 +++--- template/pkg/init.sls | 7 +++++++ template/{ => pkg}/install.sls | 2 +- template/{ => pkg}/service.sls | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) rename template/{ => pkg}/config.sls (71%) create mode 100644 template/pkg/init.sls rename template/{ => pkg}/install.sls (54%) rename template/{ => pkg}/service.sls (59%) diff --git a/template/init.sls b/template/init.sls index 1de0f0bd..18a05595 100644 --- a/template/init.sls +++ b/template/init.sls @@ -2,6 +2,4 @@ # vim: ft=sls include: - - template.install - - template.config - - template.service + - template.pkg diff --git a/template/config.sls b/template/pkg/config.sls similarity index 71% rename from template/config.sls rename to template/pkg/config.sls index 13ad6686..0b7095bf 100644 --- a/template/config.sls +++ b/template/pkg/config.sls @@ -2,11 +2,11 @@ # vim: ft=sls {%- set topdir = tpldir.split('/')[0] %} -{%- from tpldir ~ "/map.jinja" import template with context %} -{%- from tpldir ~ "/macros.jinja" import files_switch with context %} +{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{%- from salt['file.dirname'](tpldir) ~ "/macros.jinja" import files_switch with context %} include: - - template.install + - .install template-config: file.managed: diff --git a/template/pkg/init.sls b/template/pkg/init.sls new file mode 100644 index 00000000..5a3145a3 --- /dev/null +++ b/template/pkg/init.sls @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +include: + - .install + - .config + - .service diff --git a/template/install.sls b/template/pkg/install.sls similarity index 54% rename from template/install.sls rename to template/pkg/install.sls index bb45cc1a..a2e4eb72 100644 --- a/template/install.sls +++ b/template/pkg/install.sls @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from tpldir ~ "/map.jinja" import template with context %} +{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} template-pkg: pkg.installed: diff --git a/template/service.sls b/template/pkg/service.sls similarity index 59% rename from template/service.sls rename to template/pkg/service.sls index 4e4daae6..56140677 100644 --- a/template/service.sls +++ b/template/pkg/service.sls @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from tpldir ~ "/map.jinja" import template with context %} +{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} include: - - template.config + - .config template-name: service.running: From 6e7141babf2eaf8bfbbe089675f50420ccebe7c7 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 24 Feb 2019 05:40:24 +0000 Subject: [PATCH 02/13] feat(pkg): use `require` requisite between `pkg` states * `tpldot` is the equivalent of `tpldir` but using `.` instead of `/`: - https://github.com/saltstack/salt/blob/0c78d7dc894058988d171a28a11bd4a9dbf60266/salt/utils/jinja.py#L120 - https://github.com/saltstack/salt/blob/0c78d7dc894058988d171a28a11bd4a9dbf60266/salt/utils/templates.py#L145 * Implementation based on upstream issue: - https://github.com/saltstack/salt/issues/10838#issuecomment-391718086 --- template/pkg/config.sls | 2 ++ template/pkg/service.sls | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/template/pkg/config.sls b/template/pkg/config.sls index 0b7095bf..ddc67484 100644 --- a/template/pkg/config.sls +++ b/template/pkg/config.sls @@ -21,3 +21,5 @@ template-config: - user: root - group: root - template: jinja + - require: + - sls: {{ tpldot }}.install diff --git a/template/pkg/service.sls b/template/pkg/service.sls index 56140677..2449736a 100644 --- a/template/pkg/service.sls +++ b/template/pkg/service.sls @@ -6,7 +6,9 @@ include: - .config -template-name: +template-service: service.running: - name: {{ template.service.name }} - enable: True + - require: + - sls: {{ tpldot }}.config From 422c7ac212e4bb0f01a8ce0f0482bf6d92a34438 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 24 Feb 2019 06:13:40 +0000 Subject: [PATCH 03/13] feat(pkg): add `clean` states --- template/pkg/clean.sls | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 template/pkg/clean.sls diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls new file mode 100644 index 00000000..1f7b8f12 --- /dev/null +++ b/template/pkg/clean.sls @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} + +template-service-dead: + service.dead: + - name: {{ template.service.name }} + - enable: False + +template-config-absent: + file.absent: + - name: {{ template.config }} + - require: + - service: template-service-dead + +template-pkg-removed: + pkg.removed: + - name: {{ template.pkg }} + - require: + - file: template-config-absent From 2838bc904125918671ad3e73fe1f50885291bf79 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 14:09:31 +0000 Subject: [PATCH 04/13] refactor(tpldir): use `topdir` globally in place of `tpldir` * `topdir` evaluates to the formula's root directory * Maintains formula's portability by providing consistent navigation --- template/pkg/clean.sls | 4 +++- template/pkg/config.sls | 5 +++-- template/pkg/install.sls | 4 +++- template/pkg/service.sls | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls index 1f7b8f12..daf3dfb9 100644 --- a/template/pkg/clean.sls +++ b/template/pkg/clean.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} template-service-dead: service.dead: diff --git a/template/pkg/config.sls b/template/pkg/config.sls index ddc67484..b921ba18 100644 --- a/template/pkg/config.sls +++ b/template/pkg/config.sls @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=sls +{#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} -{%- from salt['file.dirname'](tpldir) ~ "/macros.jinja" import files_switch with context %} +{%- from topdir ~ "/map.jinja" import template with context %} +{%- from topdir ~ "/macros.jinja" import files_switch with context %} include: - .install diff --git a/template/pkg/install.sls b/template/pkg/install.sls index a2e4eb72..d71cbec9 100644 --- a/template/pkg/install.sls +++ b/template/pkg/install.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} template-pkg: pkg.installed: diff --git a/template/pkg/service.sls b/template/pkg/service.sls index 2449736a..b2c4dbc5 100644 --- a/template/pkg/service.sls +++ b/template/pkg/service.sls @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from salt['file.dirname'](tpldir) ~ "/map.jinja" import template with context %} +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} include: - .config From a218e914bc34b3bc55a0c726d07486e08b4d0d0b Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 11:56:30 +0000 Subject: [PATCH 05/13] refactor(topdir): use for `include` and `require` except `init.sls` * Make all `init.sls` imports relative since unnecessary there --- template/init.sls | 2 +- template/pkg/config.sls | 4 ++-- template/pkg/service.sls | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/template/init.sls b/template/init.sls index 18a05595..6d1b0ba4 100644 --- a/template/init.sls +++ b/template/init.sls @@ -2,4 +2,4 @@ # vim: ft=sls include: - - template.pkg + - .pkg diff --git a/template/pkg/config.sls b/template/pkg/config.sls index b921ba18..e9a4a290 100644 --- a/template/pkg/config.sls +++ b/template/pkg/config.sls @@ -7,7 +7,7 @@ {%- from topdir ~ "/macros.jinja" import files_switch with context %} include: - - .install + - {{ topdir }}.pkg.install template-config: file.managed: @@ -23,4 +23,4 @@ template-config: - group: root - template: jinja - require: - - sls: {{ tpldot }}.install + - sls: {{ topdir }}.pkg.install diff --git a/template/pkg/service.sls b/template/pkg/service.sls index b2c4dbc5..ea48fead 100644 --- a/template/pkg/service.sls +++ b/template/pkg/service.sls @@ -6,11 +6,11 @@ {%- from topdir ~ "/map.jinja" import template with context %} include: - - .config + - {{ topdir }}.pkg.config template-service: service.running: - name: {{ template.service.name }} - enable: True - require: - - sls: {{ tpldot }}.config + - sls: {{ topdir }}.pkg.config From d95705563c8c2d31766e9be5f53d9ecd3c9ee0ce Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 15:02:19 +0000 Subject: [PATCH 06/13] refactor(components): split components into separate subdirs * Plan based upon the following comments: - https://github.com/saltstack-formulas/template-formula/pull/48#pullrequestreview-207182085 - https://github.com/saltstack-formulas/template-formula/pull/48#discussion_r259805312 --- template/clean.sls | 7 +++++++ template/config/clean.sls | 16 ++++++++++++++++ template/{pkg/config.sls => config/file.sls} | 0 template/config/init.sls | 5 +++++ template/init.sls | 2 ++ template/pkg/clean.sls | 14 +++----------- template/pkg/init.sls | 2 -- template/service/clean.sls | 11 +++++++++++ template/service/init.sls | 5 +++++ .../{pkg/service.sls => service/running.sls} | 4 ++-- 10 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 template/clean.sls create mode 100644 template/config/clean.sls rename template/{pkg/config.sls => config/file.sls} (100%) create mode 100644 template/config/init.sls create mode 100644 template/service/clean.sls create mode 100644 template/service/init.sls rename template/{pkg/service.sls => service/running.sls} (81%) diff --git a/template/clean.sls b/template/clean.sls new file mode 100644 index 00000000..60c375e4 --- /dev/null +++ b/template/clean.sls @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +include: + - .service.clean + - .config.clean + - .pkg.clean diff --git a/template/config/clean.sls b/template/config/clean.sls new file mode 100644 index 00000000..ad0802dc --- /dev/null +++ b/template/config/clean.sls @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} +{%- from topdir ~ "/macros.jinja" import files_switch with context %} + +include: + - {{ topdir }}.service.clean + +template-config-absent: + file.absent: + - name: {{ template.config }} + - require: + - sls: {{ topdir }}.service.clean diff --git a/template/pkg/config.sls b/template/config/file.sls similarity index 100% rename from template/pkg/config.sls rename to template/config/file.sls diff --git a/template/config/init.sls b/template/config/init.sls new file mode 100644 index 00000000..465ddfea --- /dev/null +++ b/template/config/init.sls @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +include: + - .file diff --git a/template/init.sls b/template/init.sls index 6d1b0ba4..a9dc5226 100644 --- a/template/init.sls +++ b/template/init.sls @@ -3,3 +3,5 @@ include: - .pkg + - .config + - .service diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls index daf3dfb9..da522ceb 100644 --- a/template/pkg/clean.sls +++ b/template/pkg/clean.sls @@ -5,19 +5,11 @@ {%- set topdir = tpldir.split('/')[0] %} {%- from topdir ~ "/map.jinja" import template with context %} -template-service-dead: - service.dead: - - name: {{ template.service.name }} - - enable: False - -template-config-absent: - file.absent: - - name: {{ template.config }} - - require: - - service: template-service-dead +include: + - {{ topdir }}.config.clean template-pkg-removed: pkg.removed: - name: {{ template.pkg }} - require: - - file: template-config-absent + - sls: {{ topdir }}.config.clean diff --git a/template/pkg/init.sls b/template/pkg/init.sls index 5a3145a3..d3e55181 100644 --- a/template/pkg/init.sls +++ b/template/pkg/init.sls @@ -3,5 +3,3 @@ include: - .install - - .config - - .service diff --git a/template/service/clean.sls b/template/service/clean.sls new file mode 100644 index 00000000..2142822a --- /dev/null +++ b/template/service/clean.sls @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{#- Get the `topdir` from `tpldir` #} +{%- set topdir = tpldir.split('/')[0] %} +{%- from topdir ~ "/map.jinja" import template with context %} + +template-service-dead: + service.dead: + - name: {{ template.service.name }} + - enable: False diff --git a/template/service/init.sls b/template/service/init.sls new file mode 100644 index 00000000..6fe4d1a3 --- /dev/null +++ b/template/service/init.sls @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +include: + - .running diff --git a/template/pkg/service.sls b/template/service/running.sls similarity index 81% rename from template/pkg/service.sls rename to template/service/running.sls index ea48fead..963dae8a 100644 --- a/template/pkg/service.sls +++ b/template/service/running.sls @@ -6,11 +6,11 @@ {%- from topdir ~ "/map.jinja" import template with context %} include: - - {{ topdir }}.pkg.config + - {{ topdir }}.config.file template-service: service.running: - name: {{ template.service.name }} - enable: True - require: - - sls: {{ topdir }}.pkg.config + - sls: {{ topdir }}.config.file From 4443518a6349e37e039266de69666a58d79ba70a Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 15:27:24 +0000 Subject: [PATCH 07/13] refactor(include+require): use variable for duplicate values --- template/config/clean.sls | 5 +++-- template/config/file.sls | 5 +++-- template/pkg/clean.sls | 5 +++-- template/service/running.sls | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/template/config/clean.sls b/template/config/clean.sls index ad0802dc..f3ee871c 100644 --- a/template/config/clean.sls +++ b/template/config/clean.sls @@ -3,14 +3,15 @@ {#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} +{%- set sls_service_clean = topdir ~ '.service.clean' %} {%- from topdir ~ "/map.jinja" import template with context %} {%- from topdir ~ "/macros.jinja" import files_switch with context %} include: - - {{ topdir }}.service.clean + - {{ sls_service_clean }} template-config-absent: file.absent: - name: {{ template.config }} - require: - - sls: {{ topdir }}.service.clean + - sls: {{ sls_service_clean }} diff --git a/template/config/file.sls b/template/config/file.sls index e9a4a290..aca3a7fa 100644 --- a/template/config/file.sls +++ b/template/config/file.sls @@ -3,11 +3,12 @@ {#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} +{%- set sls_pkg_install = topdir ~ '.pkg.install' %} {%- from topdir ~ "/map.jinja" import template with context %} {%- from topdir ~ "/macros.jinja" import files_switch with context %} include: - - {{ topdir }}.pkg.install + - {{ sls_pkg_install }} template-config: file.managed: @@ -23,4 +24,4 @@ template-config: - group: root - template: jinja - require: - - sls: {{ topdir }}.pkg.install + - sls: {{ sls_pkg_install }} diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls index da522ceb..74a088e0 100644 --- a/template/pkg/clean.sls +++ b/template/pkg/clean.sls @@ -3,13 +3,14 @@ {#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} +{%- set sls_config_clean = topdir ~ '.config.clean' %} {%- from topdir ~ "/map.jinja" import template with context %} include: - - {{ topdir }}.config.clean + - {{ sls_config_clean }} template-pkg-removed: pkg.removed: - name: {{ template.pkg }} - require: - - sls: {{ topdir }}.config.clean + - sls: {{ sls_config_clean }} diff --git a/template/service/running.sls b/template/service/running.sls index 963dae8a..5651744b 100644 --- a/template/service/running.sls +++ b/template/service/running.sls @@ -3,14 +3,15 @@ {#- Get the `topdir` from `tpldir` #} {%- set topdir = tpldir.split('/')[0] %} +{%- set sls_config_file = topdir ~ '.config.file' %} {%- from topdir ~ "/map.jinja" import template with context %} include: - - {{ topdir }}.config.file + - {{ sls_config_file }} template-service: service.running: - name: {{ template.service.name }} - enable: True - require: - - sls: {{ topdir }}.config.file + - sls: {{ sls_config_file }} From 726fcabc6d36f25f4d5b1286d09789eede7623fa Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 16:23:59 +0000 Subject: [PATCH 08/13] docs(components): update for separation of `pkg`, `config` & `service` --- README.rst | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 1d5d1125..bfacb60c 100644 --- a/README.rst +++ b/README.rst @@ -48,10 +48,12 @@ Available states Meta-state (This is a state that includes other states) -This installs the template package, and starts the associated template service. +This installs the template package, +manages the template configuration file and then +starts the associated template service. -``template.install`` --------------------- +``template.pkg`` +---------------- This state will install the template package only. @@ -67,3 +69,30 @@ via include list. This state will start the template service and has a depency on ``template.config`` via include list. +``template.clean`` +------------------ + +Meta-state (This is a state that includes other states) + +This state will undo everything performed in the ``template`` meta-state in reverse order, i.e. +stops the service, +removes the configuration file and +then uninstalls the package. + +``template.service.clean`` +-------------------------- + +This state will stop the template service only. + +``template.config.clean`` +------------------------- + +This state will remove the configuration of the template service and has a depency on ``template.service.clean`` +via include list. + +``template.pkg.clean`` +---------------------- + +This state will remove the template package and has a depency on ``template.config.clean`` +via include list. + From bf1039ca99a86ee572d39a046d52b916f401052d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 25 Feb 2019 16:36:52 +0000 Subject: [PATCH 09/13] docs(readme): add suggested improvement to `template.service.clean` --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index bfacb60c..bf85b7f5 100644 --- a/README.rst +++ b/README.rst @@ -82,7 +82,7 @@ then uninstalls the package. ``template.service.clean`` -------------------------- -This state will stop the template service only. +This state will stop the template service and disable it at boot time. ``template.config.clean`` ------------------------- From b7356b0d413e8b9efca87e0635ae16d00c82567d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 26 Feb 2019 01:32:24 +0000 Subject: [PATCH 10/13] refactor(tplroot): use `tplroot` instead of `topdir` to match `tpldata` * Upstream feature request PR: - https://github.com/saltstack/salt/pull/51814 --- template/config/clean.sls | 10 +++++----- template/config/file.sls | 12 ++++++------ template/map.jinja | 12 ++++++------ template/pkg/clean.sls | 8 ++++---- template/pkg/install.sls | 6 +++--- template/service/clean.sls | 6 +++--- template/service/running.sls | 8 ++++---- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/template/config/clean.sls b/template/config/clean.sls index f3ee871c..db854cbd 100644 --- a/template/config/clean.sls +++ b/template/config/clean.sls @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- set sls_service_clean = topdir ~ '.service.clean' %} -{%- from topdir ~ "/map.jinja" import template with context %} -{%- from topdir ~ "/macros.jinja" import files_switch with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- set sls_service_clean = tplroot ~ '.service.clean' %} +{%- from tplroot ~ "/map.jinja" import template with context %} +{%- from tplroot ~ "/macros.jinja" import files_switch with context %} include: - {{ sls_service_clean }} diff --git a/template/config/file.sls b/template/config/file.sls index aca3a7fa..f06bc26a 100644 --- a/template/config/file.sls +++ b/template/config/file.sls @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- set sls_pkg_install = topdir ~ '.pkg.install' %} -{%- from topdir ~ "/map.jinja" import template with context %} -{%- from topdir ~ "/macros.jinja" import files_switch with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- set sls_pkg_install = tplroot ~ '.pkg.install' %} +{%- from tplroot ~ "/map.jinja" import template with context %} +{%- from tplroot ~ "/macros.jinja" import files_switch with context %} include: - {{ sls_pkg_install }} @@ -15,7 +15,7 @@ template-config: - name: {{ template.config }} - source: {{ files_switch( salt['config.get']( - topdir ~ ':tofs:files:template-config', + tplroot ~ ':tofs:files:template-config', ['example.tmpl', 'example.tmpl.jinja'] ) ) }} diff --git a/template/map.jinja b/template/map.jinja index 5bfeb2d7..7d28ed9b 100644 --- a/template/map.jinja +++ b/template/map.jinja @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # vim: ft=jinja -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} {#- Start imports as #} -{%- import_yaml topdir ~ "/defaults.yaml" or {} as default_settings %} -{%- import_yaml topdir ~ "/osfamilymap.yaml" or {} as osfamilymap %} -{%- import_yaml topdir ~ "/osmap.yaml" or {} as osmap %} -{%- import_yaml topdir ~ "/osfingermap.yaml" or {} as osfingermap %} +{%- import_yaml tplroot ~ "/defaults.yaml" or {} as default_settings %} +{%- import_yaml tplroot ~ "/osfamilymap.yaml" or {} as osfamilymap %} +{%- import_yaml tplroot ~ "/osmap.yaml" or {} as osmap %} +{%- import_yaml tplroot ~ "/osfingermap.yaml" or {} as osfingermap %} {% set defaults = salt['grains.filter_by'](default_settings, default='template', diff --git a/template/pkg/clean.sls b/template/pkg/clean.sls index 74a088e0..9b74ab56 100644 --- a/template/pkg/clean.sls +++ b/template/pkg/clean.sls @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- set sls_config_clean = topdir ~ '.config.clean' %} -{%- from topdir ~ "/map.jinja" import template with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- set sls_config_clean = tplroot ~ '.config.clean' %} +{%- from tplroot ~ "/map.jinja" import template with context %} include: - {{ sls_config_clean }} diff --git a/template/pkg/install.sls b/template/pkg/install.sls index d71cbec9..47829303 100644 --- a/template/pkg/install.sls +++ b/template/pkg/install.sls @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- from topdir ~ "/map.jinja" import template with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import template with context %} template-pkg: pkg.installed: diff --git a/template/service/clean.sls b/template/service/clean.sls index 2142822a..ae2bcbd1 100644 --- a/template/service/clean.sls +++ b/template/service/clean.sls @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- from topdir ~ "/map.jinja" import template with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import template with context %} template-service-dead: service.dead: diff --git a/template/service/running.sls b/template/service/running.sls index 5651744b..615347c0 100644 --- a/template/service/running.sls +++ b/template/service/running.sls @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{#- Get the `topdir` from `tpldir` #} -{%- set topdir = tpldir.split('/')[0] %} -{%- set sls_config_file = topdir ~ '.config.file' %} -{%- from topdir ~ "/map.jinja" import template with context %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- set sls_config_file = tplroot ~ '.config.file' %} +{%- from tplroot ~ "/map.jinja" import template with context %} include: - {{ sls_config_file }} From 2cd82e5076353d63b74cb8b655cd9799ff4ecd9e Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 26 Feb 2019 15:45:17 +0000 Subject: [PATCH 11/13] refactor(pkg): change to `package` instead * https://github.com/saltstack-formulas/template-formula/pull/48#discussion_r259951123 BREAKING CHANGE: Changing the `pkg` directory to `package` will break implementations that are depending on `pkg` for `include` or `sls`-based requisite purposes. --- README.rst | 10 +++++----- template/clean.sls | 2 +- template/config/file.sls | 6 +++--- template/init.sls | 2 +- template/{pkg => package}/clean.sls | 0 template/{pkg => package}/init.sls | 0 template/{pkg => package}/install.sls | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename template/{pkg => package}/clean.sls (100%) rename template/{pkg => package}/init.sls (100%) rename template/{pkg => package}/install.sls (100%) diff --git a/README.rst b/README.rst index bf85b7f5..0e0cd7e7 100644 --- a/README.rst +++ b/README.rst @@ -52,8 +52,8 @@ This installs the template package, manages the template configuration file and then starts the associated template service. -``template.pkg`` ----------------- +``template.package`` +-------------------- This state will install the template package only. @@ -74,7 +74,7 @@ via include list. Meta-state (This is a state that includes other states) -This state will undo everything performed in the ``template`` meta-state in reverse order, i.e. +this state will undo everything performed in the ``template`` meta-state in reverse order, i.e. stops the service, removes the configuration file and then uninstalls the package. @@ -90,8 +90,8 @@ This state will stop the template service and disable it at boot time. This state will remove the configuration of the template service and has a depency on ``template.service.clean`` via include list. -``template.pkg.clean`` ----------------------- +``template.package.clean`` +-------------------------- This state will remove the template package and has a depency on ``template.config.clean`` via include list. diff --git a/template/clean.sls b/template/clean.sls index 60c375e4..2cefe7dd 100644 --- a/template/clean.sls +++ b/template/clean.sls @@ -4,4 +4,4 @@ include: - .service.clean - .config.clean - - .pkg.clean + - .package.clean diff --git a/template/config/file.sls b/template/config/file.sls index f06bc26a..2776a5cb 100644 --- a/template/config/file.sls +++ b/template/config/file.sls @@ -3,12 +3,12 @@ {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split('/')[0] %} -{%- set sls_pkg_install = tplroot ~ '.pkg.install' %} +{%- set sls_package_install = tplroot ~ '.package.install' %} {%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/macros.jinja" import files_switch with context %} include: - - {{ sls_pkg_install }} + - {{ sls_package_install }} template-config: file.managed: @@ -24,4 +24,4 @@ template-config: - group: root - template: jinja - require: - - sls: {{ sls_pkg_install }} + - sls: {{ sls_package_install }} diff --git a/template/init.sls b/template/init.sls index a9dc5226..858a8e6e 100644 --- a/template/init.sls +++ b/template/init.sls @@ -2,6 +2,6 @@ # vim: ft=sls include: - - .pkg + - .package - .config - .service diff --git a/template/pkg/clean.sls b/template/package/clean.sls similarity index 100% rename from template/pkg/clean.sls rename to template/package/clean.sls diff --git a/template/pkg/init.sls b/template/package/init.sls similarity index 100% rename from template/pkg/init.sls rename to template/package/init.sls diff --git a/template/pkg/install.sls b/template/package/install.sls similarity index 100% rename from template/pkg/install.sls rename to template/package/install.sls From 6690ee6591697389dfe81e280bc8f85ad3ea42c3 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 26 Feb 2019 16:32:38 +0000 Subject: [PATCH 12/13] refactor(states): set state IDs based on a dependable structure * Based on: - https://github.com/saltstack-formulas/template-formula/pull/48#discussion_r259953473 - https://github.com/saltstack-formulas/template-formula/pull/48#discussion_r259956996 Consistent structure using 5 parts to the state ID naming: * 3 parts from the filename: - `template/package/install.sls` * 2 parts from the state: - `pkg.installed` * In the structure: - `----` * Putting together to get: - `template-package-install-pkg-installed` BREAKING CHANGE: Wholesale state ID changes will break implementations that are relying on the previous state IDs for requisite purposes. --- template/config/clean.sls | 2 +- template/config/file.sls | 2 +- template/package/clean.sls | 2 +- template/package/install.sls | 2 +- template/service/clean.sls | 2 +- template/service/running.sls | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/template/config/clean.sls b/template/config/clean.sls index db854cbd..5b3ee11d 100644 --- a/template/config/clean.sls +++ b/template/config/clean.sls @@ -10,7 +10,7 @@ include: - {{ sls_service_clean }} -template-config-absent: +template-config-clean-file-absent: file.absent: - name: {{ template.config }} - require: diff --git a/template/config/file.sls b/template/config/file.sls index 2776a5cb..be73822d 100644 --- a/template/config/file.sls +++ b/template/config/file.sls @@ -10,7 +10,7 @@ include: - {{ sls_package_install }} -template-config: +template-config-file-file-managed: file.managed: - name: {{ template.config }} - source: {{ files_switch( diff --git a/template/package/clean.sls b/template/package/clean.sls index 9b74ab56..8d2660f9 100644 --- a/template/package/clean.sls +++ b/template/package/clean.sls @@ -9,7 +9,7 @@ include: - {{ sls_config_clean }} -template-pkg-removed: +template-package-clean-pkg-removed: pkg.removed: - name: {{ template.pkg }} - require: diff --git a/template/package/install.sls b/template/package/install.sls index 47829303..78bdb5ea 100644 --- a/template/package/install.sls +++ b/template/package/install.sls @@ -5,6 +5,6 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import template with context %} -template-pkg: +template-package-install-pkg-installed: pkg.installed: - name: {{ template.pkg }} diff --git a/template/service/clean.sls b/template/service/clean.sls index ae2bcbd1..2074193d 100644 --- a/template/service/clean.sls +++ b/template/service/clean.sls @@ -5,7 +5,7 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import template with context %} -template-service-dead: +template-service-clean-service-dead: service.dead: - name: {{ template.service.name }} - enable: False diff --git a/template/service/running.sls b/template/service/running.sls index 615347c0..d668f85f 100644 --- a/template/service/running.sls +++ b/template/service/running.sls @@ -9,7 +9,7 @@ include: - {{ sls_config_file }} -template-service: +template-service-running-service-running: service.running: - name: {{ template.service.name }} - enable: True From 007159ac415ff62bb931478a081ade6dd0ca6e3d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 26 Feb 2019 18:34:48 +0000 Subject: [PATCH 13/13] docs(readme): fix typos --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 0e0cd7e7..744bffbf 100644 --- a/README.rst +++ b/README.rst @@ -60,13 +60,13 @@ This state will install the template package only. ``template.config`` ------------------- -This state will configure the template service and has a depency on ``template.install`` +This state will configure the template service and has a dependency on ``template.install`` via include list. ``template.service`` -------------------- -This state will start the template service and has a depency on ``template.config`` +This state will start the template service and has a dependency on ``template.config`` via include list. ``template.clean`` @@ -87,7 +87,7 @@ This state will stop the template service and disable it at boot time. ``template.config.clean`` ------------------------- -This state will remove the configuration of the template service and has a depency on ``template.service.clean`` +This state will remove the configuration of the template service and has a dependency on ``template.service.clean`` via include list. ``template.package.clean``