Skip to content

Commit

Permalink
Merge pull request #20 from aboe76/update_map.jinja
Browse files Browse the repository at this point in the history
update formula with map.jinja and style guide references, improve REA…
  • Loading branch information
javierbertoli authored Feb 10, 2019
2 parents 95e5e37 + b23c0c2 commit 92f0b8c
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 31 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
template formula
================

0.1.1 (2019-02-10)

- Update map.jinja and README
- Add tags and update VERSION and CHANGELOG

0.1.0 (2019-02-08)

- Update formula with TOFS pattern

0.0.9 (2018-12-11)

- Add Version File

0.0.8 (2018-03-02)

- Align with Saltstack Official Documenation

0.0.7 (2017-06-18)

- Fix typos and comments

0.0.6 (2015-07-1)

- Improve style and jinja to match salt-Formula

0.0.5 (2014-07-28)

- Fixed broken link to Salt Formula documentation
Expand Down
24 changes: 22 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ template-formula
================

A SaltStack formula that is empty. It has dummy content to help with a quick
start on a new formula.
start on a new formula and it serves as a style guide.

**NOTE**

Expand All @@ -27,4 +27,24 @@ Available states
``template``
------------

Installs the template package, and starts the associated template service.
Meta-state (This is a state that includes other states)

This installs the template package, and starts the associated template service.

``template.install``
--------------------

This state will install the template package only.

``template.config``
-------------------

This state will configure the template service and has a depency on ``template.install``
via include list.

``template.service``
--------------------

This state will start the template service and has a depency on ``template.config``
via include list.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# should contain the currently released version of the formula
1.0.0
0.1.0
3 changes: 3 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
template:
lookup:
master: template-master
Expand Down
3 changes: 3 additions & 0 deletions template/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{% from "template/map.jinja" import template with context %}
{% from "template/macros.jinja" import files_switch with context %}
include:
- template.install
template-config:
file.managed:
- name: {{ template.config }}
Expand Down
1 change: 1 addition & 0 deletions template/defaults.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
template:
pkg: template
config: '/etc/template'
Expand Down
45 changes: 17 additions & 28 deletions template/map.jinja
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{## Start with defaults from defaults.yaml ##}
{% import_yaml 'template/defaults.yaml' as default_settings %}
{## Start imports as ##}
{% import_yaml 'template/defaults.yaml' as defaults %}
{% import_yaml 'template/osfamilymap.yaml' ad osfamilymap %}
{% import_yaml 'template/osmap.yaml' ad osmap %}

{##
Setup variables using grains['os_family'] based logic, only add key:values
that differ from what is in defaults.yaml
##}
{% set os_family_map = salt['grains.filter_by']({
'Debian': {},
'Suse': {},
'Arch': {
"pkg" : 'template-arch',
},
'RedHat': {
"config": '/etc/template.conf',
},
}
, grain="os_family"
, merge=salt['pillar.get']('template:lookup'))
%}
{## Merge the flavor_map to the default settings ##}
{% do default_settings.template.update(os_family_map) %}
{## merge the osfamilymap ##}
{% set osfamily = salt['grains.filter_by']('osfamilymap', grain='os_family_map') or{} %}
{% do salt['defaults.merge'](defaults['template'], osfamily) %}

{## Merge in template:lookup pillar ##}
{% set template = salt['pillar.get'](
'template',
default=default_settings.template,
merge=True
)
%}
{## merge the osmap ##}
{% set osmap = salt['grains.filter_by']('osmap', grain='os') or{} %}
{% do salt['defaults.merge'](defaults['template'], osmap) %}

{## merge the lookup ##}
{% lookup = salt['pillar.get']('template:lookup', default={}, merge=True) %}
{% do salt['defaults.merge'](defaults['template'], lookup) %}

{## merge the template pillar ##}
{% set template = salt['pillar.get']('template', default=defaults['template'], merge=True) %}
17 changes: 17 additions & 0 deletions template/osfamilymap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# # vim: ft=yaml
---
Debian:
pkg: template-debian
config: /etc/template.d/custom.conf

RedHat:
pkg: template-redhat
config: /etc/template.conf

Suse:
pkg: template-suse

Arch:
pkg: template-arch

8 changes: 8 additions & 0 deletions template/osmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
Fedora:
pkg: template-fedora

Ubuntu:
pkg: template-ubuntu
3 changes: 3 additions & 0 deletions template/service.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

{% from "template/map.jinja" import template with context %}
include:
- template.config
template-name:
service.running:
- name: {{ template.service.name }}
Expand Down

0 comments on commit 92f0b8c

Please sign in to comment.