refactor: convert map.jinja to new standards
This commit is contained in:
parent
0183aed04b
commit
ee173b0041
6 changed files with 160 additions and 17 deletions
5
sudoers/defaults.yaml
Normal file
5
sudoers/defaults.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=yaml
|
||||||
|
---
|
||||||
|
sudoers:
|
||||||
|
pkg: sudo
|
|
@ -1,17 +1,55 @@
|
||||||
{% set sudoers = salt['grains.filter_by']({
|
# -*- coding: utf-8 -*-
|
||||||
'Debian': {'pkg': 'sudo'},
|
# vim: ft=jinja
|
||||||
'Ubuntu': {'pkg': 'sudo'},
|
|
||||||
'CentOS': {'pkg': 'sudo'},
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
'Fedora': {'pkg': 'sudo'},
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
'RedHat': {'pkg': 'sudo'},
|
{#- Start imports as #}
|
||||||
'Amazon': {'pkg': 'sudo'},
|
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
|
||||||
'Gentoo': {'pkg': 'app-admin/sudo'},
|
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
|
||||||
'Mint': {'pkg': 'sudo'},
|
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
|
||||||
'Arch': {'pkg': 'sudo'},
|
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
|
||||||
'Suse': {'pkg': 'sudo'},
|
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
|
||||||
'FreeBSD': {'pkg': 'sudo',
|
|
||||||
'configpath': '/usr/local/etc',
|
{#- Retrieve the config dict only once #}
|
||||||
'includedir': '/usr/local/etc/sudoers.d',
|
{%- set _config = salt['config.get'](tplroot, default={}) %}
|
||||||
'execprefix': '/usr/local/sbin',
|
|
||||||
'group': 'wheel'},
|
{%- set defaults = salt['grains.filter_by'](
|
||||||
}, merge=salt['pillar.get']('sudoers:lookup')) %}
|
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 sudoers = config %}
|
||||||
|
|
||||||
|
{#- Post-processing for specific non-YAML customisations #}
|
||||||
|
{%- if grains.os == 'MacOS' %}
|
||||||
|
{%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
|
||||||
|
{%- do sudoers.update({'rootgroup': macos_group}) %}
|
||||||
|
{%- endif %}
|
||||||
|
|
35
sudoers/osarchmap.yaml
Normal file
35
sudoers/osarchmap.yaml
Normal file
|
@ -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
|
38
sudoers/osfamilymap.yaml
Normal file
38
sudoers/osfamilymap.yaml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- 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: {}
|
||||||
|
---
|
||||||
|
Debian: {}
|
||||||
|
|
||||||
|
RedHat: {}
|
||||||
|
|
||||||
|
Suse: {}
|
||||||
|
|
||||||
|
Gentoo:
|
||||||
|
pkg: app-admin/sudo
|
||||||
|
|
||||||
|
Arch: {}
|
||||||
|
|
||||||
|
Alpine: {}
|
||||||
|
|
||||||
|
FreeBSD:
|
||||||
|
configpath: /usr/local/etc
|
||||||
|
includedir: /usr/local/etc/sudoers.d
|
||||||
|
execprefix: /usr/local/sbin
|
||||||
|
group: wheel
|
||||||
|
|
||||||
|
OpenBSD: {}
|
||||||
|
|
||||||
|
Solaris: {}
|
||||||
|
|
||||||
|
Windows: {}
|
||||||
|
|
||||||
|
MacOS: {}
|
14
sudoers/osfingermap.yaml
Normal file
14
sudoers/osfingermap.yaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# -*- 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: {}
|
||||||
|
---
|
||||||
|
# os: Debian
|
||||||
|
osfingermap: {}
|
13
sudoers/osmap.yaml
Normal file
13
sudoers/osmap.yaml
Normal file
|
@ -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 a new issue