refactor: improve reusability using an unique keyword TEMPLATE

BREAKING CHANGE: changed all state names and ids
This commit is contained in:
Dafydd Jones 2019-11-22 22:45:32 +00:00
parent 341f495336
commit 2e8ded6565
39 changed files with 120 additions and 120 deletions

View file

@ -1,9 +1,9 @@
name: template name: TEMPLATE
os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS
version: 3.3.4 version: 3.3.4
release: 1 release: 1
minimum_version: 2017.7 minimum_version: 2017.7
summary: template formula summary: TEMPLATE formula
description: Formula to use as a template for other formulas description: Formula to use as a template for other formulas
top_level_dir: template top_level_dir: TEMPLATE

View file

@ -4,13 +4,13 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
include: include:
- {{ sls_service_clean }} - {{ sls_service_clean }}
template-config-clean-file-absent: TEMPLATE-config-clean-file-absent:
file.absent: file.absent:
- name: {{ template.config }} - name: {{ TEMPLATE.config }}
- require: - require:
- sls: {{ sls_service_clean }} - sls: {{ sls_service_clean }}

View file

@ -4,25 +4,25 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %} {%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include: include:
- {{ sls_package_install }} - {{ sls_package_install }}
template-config-file-file-managed: TEMPLATE-config-file-file-managed:
file.managed: file.managed:
- name: {{ template.config }} - name: {{ TEMPLATE.config }}
- source: {{ files_switch(['example.tmpl'], - source: {{ files_switch(['example.tmpl'],
lookup='template-config-file-file-managed' lookup='TEMPLATE-config-file-file-managed'
) )
}} }}
- mode: 644 - mode: 644
- user: root - user: root
- group: {{ template.rootgroup }} - group: {{ TEMPLATE.rootgroup }}
- makedirs: True - makedirs: True
- template: jinja - template: jinja
- require: - require:
- sls: {{ sls_package_install }} - sls: {{ sls_package_install }}
- context: - context:
template: {{ template | json }} TEMPLATE: {{ TEMPLATE | json }}

View file

@ -1,15 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
template: TEMPLATE:
pkg: pkg:
name: template name: TEMPLATE
rootgroup: root rootgroup: root
config: '/etc/template' config: '/etc/TEMPLATE'
service: service:
name: template name: TEMPLATE
subcomponent: subcomponent:
config: '/etc/template-subcomponent-formula.conf' config: '/etc/TEMPLATE-subcomponent-formula.conf'
# Just here for testing # Just here for testing
added_in_defaults: defaults_value added_in_defaults: defaults_value
winner: defaults winner: defaults

View file

@ -6,6 +6,6 @@
This is another example file from SaltStack template-formula. This is another example file from SaltStack template-formula.
# This is here for testing purposes # This is here for testing purposes
{{ template | json }} {{ TEMPLATE | json }}
winner of the merge: {{ template['winner'] }} winner of the merge: {{ TEMPLATE['winner'] }}

View file

@ -46,11 +46,11 @@
) )
%} %}
{#- Change **template** to match with your formula's name and then remove this line #} {#- Change **TEMPLATE** to match with your formula's name and then remove this line #}
{%- set template = config %} {%- set TEMPLATE = config %}
{#- Post-processing for specific non-YAML customisations #} {#- Post-processing for specific non-YAML customisations #}
{%- if grains.os == 'MacOS' %} {%- if grains.os == 'MacOS' %}
{%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %} {%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- do template.update({'rootgroup': macos_group}) %} {%- do TEMPLATE.update({'rootgroup': macos_group}) %}
{%- endif %} {%- endif %}

View file

@ -12,23 +12,23 @@
--- ---
Debian: Debian:
pkg: pkg:
name: template-debian name: TEMPLATE-debian
config: /etc/template.d/custom.conf config: /etc/TEMPLATE.d/custom.conf
RedHat: RedHat:
pkg: pkg:
name: template-redhat name: TEMPLATE-redhat
config: /etc/template.conf config: /etc/TEMPLATE.conf
Suse: Suse:
pkg: pkg:
name: template-suse name: TEMPLATE-suse
Gentoo: {} Gentoo: {}
Arch: Arch:
pkg: pkg:
name: template-arch name: TEMPLATE-arch
service: service:
name: service-arch name: service-arch

View file

@ -12,11 +12,11 @@
--- ---
# os: Ubuntu # os: Ubuntu
Ubuntu-18.04: Ubuntu-18.04:
config: /etc/template.d/custom-ubuntu-18.04.conf config: /etc/TEMPLATE.d/custom-ubuntu-18.04.conf
# os: CentOS # os: CentOS
CentOS-6: CentOS-6:
pkg: pkg:
name: template-centos-6 name: TEMPLATE-centos-6
config: /etc/template.d/custom-centos-6.conf config: /etc/TEMPLATE.d/custom-centos-6.conf
CentOS-7: {} CentOS-7: {}

View file

@ -13,15 +13,15 @@
# os_family: Debian # os_family: Debian
Ubuntu: Ubuntu:
pkg: pkg:
name: template-ubuntu name: TEMPLATE-ubuntu
config: /etc/template.d/custom-ubuntu.conf config: /etc/TEMPLATE.d/custom-ubuntu.conf
Raspbian: {} Raspbian: {}
# os_family: RedHat # os_family: RedHat
Fedora: Fedora:
pkg: pkg:
name: template-fedora name: TEMPLATE-fedora
service: service:
name: service-fedora name: service-fedora

View file

@ -4,13 +4,13 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_clean = tplroot ~ '.config.clean' %} {%- set sls_config_clean = tplroot ~ '.config.clean' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
include: include:
- {{ sls_config_clean }} - {{ sls_config_clean }}
template-package-clean-pkg-removed: TEMPLATE-package-clean-pkg-removed:
pkg.removed: pkg.removed:
- name: {{ template.pkg.name }} - name: {{ TEMPLATE.pkg.name }}
- require: - require:
- sls: {{ sls_config_clean }} - sls: {{ sls_config_clean }}

View file

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
TEMPLATE-package-install-pkg-installed:
pkg.installed:
- name: {{ TEMPLATE.pkg.name }}

View file

@ -3,9 +3,9 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
template-service-clean-service-dead: TEMPLATE-service-clean-service-dead:
service.dead: service.dead:
- name: {{ template.service.name }} - name: {{ TEMPLATE.service.name }}
- enable: False - enable: False

View file

@ -4,14 +4,14 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
include: include:
- {{ sls_config_file }} - {{ sls_config_file }}
template-service-running-service-running: TEMPLATE-service-running-service-running:
service.running: service.running:
- name: {{ template.service.name }} - name: {{ TEMPLATE.service.name }}
- enable: True - enable: True
- require: - require:
- sls: {{ sls_config_file }} - sls: {{ sls_config_file }}

View file

@ -4,13 +4,13 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
include: include:
- {{ sls_service_clean }} - {{ sls_service_clean }}
template-subcomponent-config-clean-file-absent: TEMPLATE-subcomponent-config-clean-file-absent:
file.absent: file.absent:
- name: {{ template.subcomponent.config }} - name: {{ TEMPLATE.subcomponent.config }}
- watch_in: - watch_in:
- sls: {{ sls_service_clean }} - sls: {{ sls_service_clean }}

View file

@ -4,23 +4,23 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import template with context %} {%- from tplroot ~ "/map.jinja" import TEMPLATE with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include: include:
- {{ sls_config_file }} - {{ sls_config_file }}
template-subcomponent-config-file-file-managed: TEMPLATE-subcomponent-config-file-file-managed:
file.managed: file.managed:
- name: {{ template.subcomponent.config }} - name: {{ TEMPLATE.subcomponent.config }}
- source: {{ files_switch(['subcomponent-example.tmpl'], - source: {{ files_switch(['subcomponent-example.tmpl'],
lookup='template-subcomponent-config-file-file-managed', lookup='TEMPLATE-subcomponent-config-file-file-managed',
use_subpath=True use_subpath=True
) )
}} }}
- mode: 644 - mode: 644
- user: root - user: root
- group: {{ template.rootgroup }} - group: {{ TEMPLATE.rootgroup }}
- makedirs: True - makedirs: True
- template: jinja - template: jinja
- require_in: - require_in:

View file

@ -8,7 +8,7 @@ Contributing documentation
.. |docs| image:: https://readthedocs.org/projects/docs/badge/?version=latest .. |docs| image:: https://readthedocs.org/projects/docs/badge/?version=latest
:alt: Documentation Status :alt: Documentation Status
:scale: 100% :scale: 100%
:target: https://template-formula.readthedocs.io/en/latest/?badge=latest :target: https://TEMPLATE-formula.readthedocs.io/en/latest/?badge=latest
Toolchain Toolchain
^^^^^^^^^ ^^^^^^^^^

View file

@ -1,14 +1,14 @@
.. _readme: .. _readme:
template-formula TEMPLATE-formula
================ ================
|img_travis| |img_sr| |img_travis| |img_sr|
.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/template-formula.svg?branch=master .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/TEMPLATE-formula.svg?branch=master
:alt: Travis CI Build Status :alt: Travis CI Build Status
:scale: 100% :scale: 100%
:target: https://travis-ci.com/saltstack-formulas/template-formula :target: https://travis-ci.com/saltstack-formulas/TEMPLATE-formula
.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
:alt: Semantic Release :alt: Semantic Release
:scale: 100% :scale: 100%
@ -53,79 +53,79 @@ Available states
.. contents:: .. contents::
:local: :local:
``template`` ``TEMPLATE``
^^^^^^^^^^^^ ^^^^^^^^^^^^
*Meta-state (This is a state that includes other states)*. *Meta-state (This is a state that includes other states)*.
This installs the template package, This installs the TEMPLATE package,
manages the template configuration file and then manages the TEMPLATE configuration file and then
starts the associated template service. starts the associated TEMPLATE service.
``template.package`` ``TEMPLATE.package``
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
This state will install the template package only. This state will install the TEMPLATE package only.
``template.config`` ``TEMPLATE.config``
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
This state will configure the template service and has a dependency on ``template.install`` This state will configure the TEMPLATE service and has a dependency on ``TEMPLATE.install``
via include list. via include list.
``template.service`` ``TEMPLATE.service``
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
This state will start the template service and has a dependency on ``template.config`` This state will start the TEMPLATE service and has a dependency on ``TEMPLATE.config``
via include list. via include list.
``template.clean`` ``TEMPLATE.clean``
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
*Meta-state (This is a state that includes other states)*. *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, stops the service,
removes the configuration file and removes the configuration file and
then uninstalls the package. then uninstalls the package.
``template.service.clean`` ``TEMPLATE.service.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will stop the template service and disable it at boot time. This state will stop the TEMPLATE service and disable it at boot time.
``template.config.clean`` ``TEMPLATE.config.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the configuration of the template service and has a This state will remove the configuration of the TEMPLATE service and has a
dependency on ``template.service.clean`` via include list. dependency on ``TEMPLATE.service.clean`` via include list.
``template.package.clean`` ``TEMPLATE.package.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the template package and has a depency on This state will remove the TEMPLATE package and has a depency on
``template.config.clean`` via include list. ``TEMPLATE.config.clean`` via include list.
``template.subcomponent`` ``TEMPLATE.subcomponent``
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
*Meta-state (This is a state that includes other states)*. *Meta-state (This is a state that includes other states)*.
This state installs a subcomponent configuration file before This state installs a subcomponent configuration file before
configuring and starting the template service. configuring and starting the TEMPLATE service.
``template.subcomponent.config`` ``TEMPLATE.subcomponent.config``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will configure the template subcomponent and has a This state will configure the TEMPLATE subcomponent and has a
dependency on ``template.config`` via include list. dependency on ``TEMPLATE.config`` via include list.
``template.subcomponent.config.clean`` ``TEMPLATE.subcomponent.config.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the configuration of the template subcomponent This state will remove the configuration of the TEMPLATE subcomponent
and reload the template service by a dependency on and reload the TEMPLATE service by a dependency on
``template.service.running`` via include list and ``watch_in`` ``TEMPLATE.service.running`` via include list and ``watch_in``
requisite. requisite.
Testing Testing
@ -151,7 +151,7 @@ e.g. ``debian-9-2019-2-py3``.
``bin/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 ``TEMPLATE`` main state, ready for testing.
``bin/kitchen verify`` ``bin/kitchen verify``
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -162,7 +162,7 @@ provisioner:
log_level: debug log_level: debug
salt_install: none salt_install: none
require_chef: false require_chef: false
formula: template formula: TEMPLATE
salt_copy_filter: salt_copy_filter:
- .kitchen - .kitchen
- .git - .git
@ -183,15 +183,15 @@ suites:
state_top: state_top:
base: base:
'*': '*':
- template - TEMPLATE
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- template - TEMPLATE
- define_roles - define_roles
pillars_from_files: pillars_from_files:
template.sls: pillar.example TEMPLATE.sls: pillar.example
define_roles.sls: test/salt/pillar/define_roles.sls define_roles.sls: test/salt/pillar/define_roles.sls
verifier: verifier:
inspec_tests: inspec_tests:
@ -203,15 +203,15 @@ suites:
state_top: state_top:
base: base:
'*': '*':
- template - TEMPLATE
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- template - TEMPLATE
- define_roles - define_roles
pillars_from_files: pillars_from_files:
template.sls: test/salt/pillar/centos6.sls TEMPLATE.sls: test/salt/pillar/centos6.sls
define_roles.sls: test/salt/pillar/define_roles.sls define_roles.sls: test/salt/pillar/define_roles.sls
verifier: verifier:
inspec_tests: inspec_tests:

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
template: TEMPLATE:
lookup: lookup:
master: template-master master: template-master
# Just for testing purposes # Just for testing purposes
@ -33,7 +33,7 @@ template:
# All aspects of path/file resolution are customisable using the options below. # All aspects of path/file resolution are customisable using the options below.
# This is unnecessary in most cases; there are sensible defaults. # This is unnecessary in most cases; there are sensible defaults.
# Default path: salt://< path_prefix >/< dirs.files >/< dirs.default > # Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
# I.e.: salt://template/files/default # I.e.: salt://TEMPLATE/files/default
# path_prefix: template_alt # path_prefix: template_alt
# dirs: # dirs:
# files: files_alt # files: files_alt
@ -41,15 +41,15 @@ template:
# The entries under `source_files` are prepended to the default source files # The entries under `source_files` are prepended to the default source files
# given for the state # given for the state
# source_files: # source_files:
# template-config-file-file-managed: # TEMPLATE-config-file-file-managed:
# - 'example_alt.tmpl' # - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja' # - 'example_alt.tmpl.jinja'
# For testing purposes # For testing purposes
source_files: source_files:
template-config-file-file-managed: TEMPLATE-config-file-file-managed:
- 'example.tmpl.jinja' - 'example.tmpl.jinja'
template-subcomponent-config-file-file-managed: TEMPLATE-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja' - 'subcomponent-example.tmpl.jinja'
# Just for testing purposes # Just for testing purposes

View file

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import template with context %}
template-package-install-pkg-installed:
pkg.installed:
- name: {{ template.pkg.name }}

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
control 'template configuration' do control 'TEMPLATE configuration' do
title 'should match desired lines' title 'should match desired lines'
describe file('/etc/template-formula.conf') do describe file('/etc/template-formula.conf') do
@ -24,8 +24,8 @@ control 'template configuration' do
should include( should include(
'"tofs": {"files_switch": ["any/path/can/be/used/here", "id", '\ '"tofs": {"files_switch": ["any/path/can/be/used/here", "id", '\
'"roles", "osfinger", "os", "os_family"], "source_files": '\ '"roles", "osfinger", "os", "os_family"], "source_files": '\
'{"template-config-file-file-managed": ["example.tmpl.jinja"], '\ '{"TEMPLATE-config-file-file-managed": ["example.tmpl.jinja"], '\
'"template-subcomponent-config-file-file-managed": '\ '"TEMPLATE-subcomponent-config-file-file-managed": '\
'["subcomponent-example.tmpl.jinja"]}' '["subcomponent-example.tmpl.jinja"]}'
) )
end end

View file

@ -4,7 +4,7 @@
package_name = 'bash' package_name = 'bash'
package_name = 'cronie' if (os[:name] == 'centos') && os[:release].start_with?('6') package_name = 'cronie' if (os[:name] == 'centos') && os[:release].start_with?('6')
control 'template package' do control 'TEMPLATE package' do
title 'should be installed' title 'should be installed'
describe package(package_name) do describe package(package_name) do

View file

@ -4,7 +4,7 @@
service_name = 'systemd-udevd' service_name = 'systemd-udevd'
service_name = 'crond' if (os[:name] == 'centos') && os[:release].start_with?('6') service_name = 'crond' if (os[:name] == 'centos') && os[:release].start_with?('6')
control 'template service' do control 'TEMPLATE service' do
impact 0.5 impact 0.5
title 'should be running and enabled' title 'should be running and enabled'

View file

@ -1,9 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
control 'template subcomponent configuration' do control 'TEMPLATE subcomponent configuration' do
title 'should match desired lines' title 'should match desired lines'
describe file('/etc/template-subcomponent-formula.conf') do describe file('/etc/TEMPLATE-subcomponent-formula.conf') do
it { should be_file } it { should be_file }
it { should be_owned_by 'root' } it { should be_owned_by 'root' }
it { should be_grouped_into 'root' } it { should be_grouped_into 'root' }
@ -11,7 +11,7 @@ control 'template subcomponent configuration' do
its('content') do its('content') do
should include( should include(
'# File managed by Salt at '\ '# File managed by Salt at '\
'<salt://template/subcomponent/config/files/default/'\ '<salt://TEMPLATE/subcomponent/config/files/default/'\
'subcomponent-example.tmpl.jinja>.' 'subcomponent-example.tmpl.jinja>.'
) )
end end

View file

@ -2,10 +2,10 @@
# vim: ft=yaml # vim: ft=yaml
--- ---
name: default name: default
title: template formula title: TEMPLATE formula
maintainer: SaltStack Formulas maintainer: SaltStack Formulas
license: Apache-2.0 license: Apache-2.0
summary: Verify that the template formula is setup and configured correctly summary: Verify that the TEMPLATE formula is setup and configured correctly
supports: supports:
- platform-name: debian - platform-name: debian
- platform-name: ubuntu - platform-name: ubuntu

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
template: TEMPLATE:
lookup: lookup:
master: template-master master: template-master
# Just for testing purposes # Just for testing purposes
@ -45,9 +45,9 @@ template:
# For testing purposes # For testing purposes
source_files: source_files:
template-config-file-file-managed: TEMPLATE-config-file-file-managed:
- 'example.tmpl.jinja' - 'example.tmpl.jinja'
template-subcomponent-config-file-file-managed: TEMPLATE-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja' - 'subcomponent-example.tmpl.jinja'
# Just for testing purposes # Just for testing purposes