apache-formula/apache/map.jinja
noelmcloughlin 47818fc360 refactor(formula): align to template-formula & improve ci features
FEATURE: Archlinux support
FEATURE: Windows support
FEATURE: Enhanced CI/CD
FEATURE: modular states

BREAKING CHANGE: 'apache.sls' converted to new style 'init.ssl'
BREAKING CHANGE: "logrotate.sls" became "config/logrotate.sls"
BREAKING CHANGE: "debian_full.sls" became "config/debian_full.sls"
BREAKING CHANGE: "flags.sls" became "config/flags.sls"
BREAKING CHANGE: "manage_security" became "config/manage_security.sls"
BREAKING CHANGE: "mod_*.sls" became "config/mod_*.sls"
BREAKING CHANGE: "no_default_host.sls" became "config/no_default_host.sls"
BREAKING CHANGE: "own_default_host.sls" became "config/own_default_host.sls"
BREAKING CHANGE: "register_site.sls" became "config/register_site.sls"
BREAKING CHANGE: "server_status.sls" became "config/server_status.sls"
BREAKING CHANGE: "vhosts/" became "config/vhosts/"
BREAKING CHANGE: "mod_security/" became "config/mod_security/"

NOT-BREAKING CHANGE: 'config.sls' became 'config/init.sls'
NOT-BREAKING CHANGE: 'uninstall.sls' symlinked to 'clean.sls'
2020-10-05 14:24:15 +01:00

80 lines
2.6 KiB
Django/Jinja

# -*- coding: utf-8 -*-
# vim: ft=jinja
{%- set tplroot = tpldir.split('/')[0] %}
{%- 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 %}
{%- import_yaml tplroot ~ "/oscodenamemap.yaml" as oscodename %}
{%- import_yaml tplroot ~ "/modsecurity.yaml" as modsec %}
{#- Retrieve the config dict only once #}
{%- set _config = salt['config.get'](tplroot, default={}) %}
{%- 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'](
oscodename,
grain='oscodename',
merge=salt['grains.filter_by'](
osfingermap,
grain='osfinger',
merge=salt['grains.filter_by'](
modsec,
grain='os_family',
merge=salt['grains.filter_by'](
_config,
default='lookup'
)
)
)
)
)
)
)
)
%}
{%- set config = salt['grains.filter_by'](
{'defaults': defaults},
default='defaults',
merge=_config
)
%}
{%- set apache = config %}
{#- Post-processing for specific non-YAML customisations #}
{%- if grains.os_family == 'MacOS' %}
{%- set rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %}
{%- set rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- do apache.update({'rootuser': rootgroup}) %}
{%- do apache.update({'rootgroup': rootgroup}) %}
{%- elif grains.os_family == 'Windows' %}
{%- set rootuser = salt['cmd.run']("id -un") %}
{%- do apache.update({'rootuser': rootuser}) %}
{%- endif %}
{# legacy pillar support #}
{%- if 'server' in apache.lookup and apache.lookup.server is string %}
{%- do apache.pkg.update({'name': apache.server}) %}
{%- endif %}
{%- if 'service' in apache.lookup and apache.lookup.service is string %}
{%- do apache.service.update({'name': apache.service}) %}
{%- endif %}
{%- if 'configfile' in apache and apache.configfile is string %}
{%- do apache.update({'config': apache.configfile}) %}
{%- endif %}