Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map.jinja and add more OSes #23

Merged
merged 2 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
template formula
================

0.1.2 (2019-02-12)

- Update map.jinja, osfamilymap.yaml & osmap.yaml

0.1.1 (2019-02-10)

- Update map.jinja and README
Expand Down
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
0.1.0
0.1.2
22 changes: 11 additions & 11 deletions template/map.jinja
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

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

{## merge the osfamilymap ##}
{% set osfamily = salt['grains.filter_by']('osfamilymap', grain='os_family_map') or{} %}
{## Merge the osfamilymap ##}
{% set osfamily = salt['grains.filter_by'](osfamilymap, grain='os_family') or {} %}
{% do salt['defaults.merge'](defaults['template'], osfamily) %}

{## merge the osmap ##}
{% set osmap = salt['grains.filter_by']('osmap', grain='os') or{} %}
{% do salt['defaults.merge'](defaults['template'], osmap) %}
{## Merge the osmap ##}
{% set os = salt['grains.filter_by'](osmap, grain='os') or {} %}
{% do salt['defaults.merge'](defaults['template'], os) %}

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

{## merge the template pillar ##}
{## Merge the template pillar ##}
{% set template = salt['pillar.get']('template', default=defaults['template'], merge=True) %}
18 changes: 16 additions & 2 deletions template/osfamilymap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# # vim: ft=yaml
# vim: ft=yaml
#
# Setup variables using grains['os_family'] based logic.
# Only add key:values that differ from `defaults.yaml`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that adding all these empty os_familys hashes might confuse a newcomer and let her assume that they have to be listed even if not covered by the formula?

In that case, perhaps the line above can be rephrased, like

# You just need to add the key:values for an `os_family` that differ from `defaults.yaml`.
# Only add an `os_family` which is/will be supported by the formula (empty `os_family`s
# do not need to be listed, just added here as an example)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, just wanted to revive the useful comment that was in the map.jinja previously and show a list of OSes that formulas support. I do feel like I've come across the use of {} before somewhere... perhaps a situation where the OS family (e.g. Debian) makes no changes to the defaults yet the OS derivative (e.g. Ubuntu) does? Maybe just used to explicitly define the OSes?

In any case, your suggestion is excellent and I'll incorporate that.

---
Debian:
pkg: template-debian
Expand All @@ -12,6 +15,17 @@ RedHat:
Suse:
pkg: template-suse

Gentoo: {}

Arch:
pkg: template-arch


javierbertoli marked this conversation as resolved.
Show resolved Hide resolved
Alpine: {}

FreeBSD: {}

OpenBSD: {}

Windows: {}

MacOS: {}
11 changes: 9 additions & 2 deletions template/osmap.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os'] based logic.
# Only add key:values that differ from `defaults.yaml` + `os_family.yaml`.
---
javierbertoli marked this conversation as resolved.
Show resolved Hide resolved
Ubuntu:
pkg: template-ubuntu

Fedora:
pkg: template-fedora
javierbertoli marked this conversation as resolved.
Show resolved Hide resolved

Ubuntu:
pkg: template-ubuntu
Raspbian: {}

SmartOS: {}