Skip to content

Commit

Permalink
refactor(include+require): use variable for duplicate values
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Feb 28, 2019
1 parent d957055 commit 4443518
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions template/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 3 additions & 2 deletions template/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -23,4 +24,4 @@ template-config:
- group: root
- template: jinja
- require:
- sls: {{ topdir }}.pkg.install
- sls: {{ sls_pkg_install }}
5 changes: 3 additions & 2 deletions template/pkg/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 3 additions & 2 deletions template/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 4443518

Please sign in to comment.