-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sub-component): manage a dedicated configuration file
* pillar.example (template.subcomponent): configurable sub-component destination. (template.tofs.source_files): override sub-component template * template/init.sls (include): setup sub-component last. * template/clean.sls (include): clean sub-component first. * template/subcomponent/init.sls: include the only setup state “config”. * template/subcomponent/config/init.sls: include the only config state “file”. * template/subcomponent/config/file.sls: manage the sub-component configuration file. It requires the main component configuration. * template/subcomponent/files/default/subcomponent-example.tmpl.jinja: jinja template for the sub-component. * template/subcomponent/files/default/subcomponent-example.tmpl: static configuration for the sub-component. * template/subcomponent/clean.sls: include the only cleanup state “config”. * template/subcomponent/config/clean.sls: remove the sub-component configuration file.
- Loading branch information
Showing
10 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# vim: ft=sls | ||
|
||
include: | ||
- .subcomponent.clean | ||
- .service.clean | ||
- .config.clean | ||
- .package.clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ include: | |
- .package | ||
- .config | ||
- .service | ||
- .subcomponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .config.clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- set sls_service_running = tplroot ~ '.service.running' %} | ||
{%- from tplroot ~ "/map.jinja" import template with context %} | ||
include: | ||
- {{ sls_service_running }} | ||
template-subcomponent-config-clean-file-absent: | ||
file.absent: | ||
- name: {{ template.subcomponent.config }} | ||
- watch_in: | ||
- sls: {{ sls_service_running }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- 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 template with context %} | ||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} | ||
include: | ||
- {{ sls_config_file }} | ||
template-subcomponent-config-file-file-managed: | ||
file.managed: | ||
- name: {{ template.subcomponent.config }} | ||
- source: {{ files_switch(['subcomponent-example.tmpl'], | ||
lookup='template-subcomponent-config-file-file-managed' | ||
) | ||
}} | ||
- mode: 644 | ||
- user: root | ||
- group: {{ template.rootgroup }} | ||
- makedirs: True | ||
- template: jinja | ||
- require_in: | ||
- sls: {{ sls_config_file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .file |
6 changes: 6 additions & 0 deletions
6
template/subcomponent/files/default/subcomponent-example.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
######################################################################## | ||
# File managed by Salt at <{{ source }}>. | ||
# Your changes will be overwritten. | ||
######################################################################## | ||
|
||
This is a subcomponent example file from SaltStack template-formula. |
6 changes: 6 additions & 0 deletions
6
template/subcomponent/files/default/subcomponent-example.tmpl.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
######################################################################## | ||
# File managed by Salt at <{{ source }}>. | ||
# Your changes will be overwritten. | ||
######################################################################## | ||
|
||
This is another subcomponent example file from SaltStack template-formula. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .config |