refactor(pillar): sync map.jinja with template-formula
This commit is contained in:
parent
dbc811f1dc
commit
cdd85c68c3
|
@ -1,4 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
---
|
||||
path_localtime: /etc/localtime
|
||||
path_zoneinfo: /usr/share/zoneinfo/
|
||||
pkgname: tzdata
|
||||
timezone:
|
||||
name: Europe/Berlin
|
||||
utc: true
|
||||
path_localtime: /etc/localtime
|
||||
path_zoneinfo: /usr/share/zoneinfo/
|
||||
pkg:
|
||||
name: tzdata
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
# This state configures the timezone.
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{%- set timezone = salt['pillar.get']('timezone:name', 'Europe/Berlin') %}
|
||||
{%- set utc = salt['pillar.get']('timezone:utc', True) %}
|
||||
{% from "timezone/map.jinja" import confmap with context %}
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- from tplroot ~ "/map.jinja" import timezone with context %}
|
||||
|
||||
timezone_setting:
|
||||
timezone.system:
|
||||
- name: {{ timezone }}
|
||||
- utc: {{ utc }}
|
||||
- name: {{ timezone.name }}
|
||||
- utc: {{ timezone.utc }}
|
||||
|
||||
{%- if grains.os not in ('MacOS', 'Windows') %}
|
||||
{%- if grains.os not in ('MacOS', 'Windows') %}
|
||||
|
||||
timezone_packages:
|
||||
pkg.installed:
|
||||
- name: {{ confmap.pkgname }}
|
||||
- name: {{ timezone.pkg.name }}
|
||||
|
||||
timezone_symlink:
|
||||
file.symlink:
|
||||
- name: {{ confmap.path_localtime }}
|
||||
- target: {{ confmap.path_zoneinfo }}{{ timezone }}
|
||||
- name: {{ timezone.path_localtime }}
|
||||
- target: {{ timezone.path_zoneinfo }}{{ timezone.name }}
|
||||
- force: true
|
||||
- require:
|
||||
- pkg: {{ confmap.pkgname }}
|
||||
- pkg: {{ timezone.pkg.name }}
|
||||
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
|
|
@ -1,15 +1,49 @@
|
|||
{% import_yaml "timezone/defaults.yaml" as defaults %}
|
||||
{% import_yaml "timezone/osfamilymap.yaml" as osfamilymap %}
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=jinja
|
||||
|
||||
{% set osfam = salt['grains.filter_by'](
|
||||
osfamilymap,
|
||||
grain='os_family'
|
||||
) or {} %}
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{#- Start imports as #}
|
||||
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
|
||||
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
|
||||
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
|
||||
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
|
||||
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
|
||||
|
||||
{% do salt['defaults.merge'](defaults, osfam) %}
|
||||
{#- Retrieve the config dict only once #}
|
||||
{%- set _config = salt['config.get'](tplroot, default={}) %}
|
||||
|
||||
{%- set confmap = salt['pillar.get'](
|
||||
'timezone:lookup',
|
||||
default=defaults,
|
||||
merge=True,
|
||||
) %}
|
||||
{%- set defaults = salt['grains.filter_by'](
|
||||
default_settings,
|
||||
default=tplroot,
|
||||
merge=salt['grains.filter_by'](
|
||||
osarchmap,
|
||||
grain='osarch',
|
||||
merge=salt['grains.filter_by'](
|
||||
osfamilymap,
|
||||
grain='os_family',
|
||||
merge=salt['grains.filter_by'](
|
||||
osmap,
|
||||
grain='os',
|
||||
merge=salt['grains.filter_by'](
|
||||
osfingermap,
|
||||
grain='osfinger',
|
||||
merge=salt['grains.filter_by'](
|
||||
_config,
|
||||
default='lookup'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
%}
|
||||
|
||||
{%- set config = salt['grains.filter_by'](
|
||||
{'defaults': defaults},
|
||||
default='defaults',
|
||||
merge=_config
|
||||
)
|
||||
%}
|
||||
|
||||
{%- set timezone = config %}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['osarch'] based logic.
|
||||
# You just need to add the key:values for an `osarch` that differ
|
||||
# from `defaults.yaml`.
|
||||
# Only add an `osarch` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `osarch` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osarch: {}
|
||||
---
|
||||
amd64:
|
||||
arch: amd64
|
||||
|
||||
x86_64:
|
||||
arch: amd64
|
||||
|
||||
386:
|
||||
arch: 386
|
||||
|
||||
arm64:
|
||||
arch: arm64
|
||||
|
||||
armv6l:
|
||||
arch: armv6l
|
||||
|
||||
armv7l:
|
||||
arch: armv7l
|
||||
|
||||
ppc64le:
|
||||
arch: ppc64le
|
||||
|
||||
s390x:
|
||||
arch: s390x
|
|
@ -1,8 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['os_family'] based logic.
|
||||
# You just need to add the key:values for an `os_family` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml`.
|
||||
# Only add an `os_family` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os_family` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osfamilymap: {}
|
||||
---
|
||||
Suse:
|
||||
pkgname: timezone
|
||||
pkg:
|
||||
name: timezone
|
||||
|
||||
FreeBSD:
|
||||
pkgname: zoneinfo
|
||||
pkg:
|
||||
name: zoneinfo
|
||||
|
||||
Gentoo:
|
||||
pkgname: sys-libs/timezone-data
|
||||
pkg:
|
||||
name: sys-libs/timezone-data
|
||||
|
||||
MacOS: {}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['osfinger'] based logic.
|
||||
# You just need to add the key:values for an `osfinger` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`.
|
||||
# Only add an `osfinger` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os_finger` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osfingermap: {}
|
||||
---
|
||||
osfingermap: {}
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['os'] based logic.
|
||||
# You just need to add the key:values for an `os` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`.
|
||||
# Only add an `os` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osmap: {}
|
||||
---
|
||||
osmap: {}
|
Loading…
Reference in New Issue