apache-formula/apache/config/file.sls
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

167 lines
4.5 KiB
Plaintext

# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import apache with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include:
- {{ sls_service_running }}
- {{ sls_package_install }}
apache-config-file-directory-logdir:
file.directory:
- name: {{ apache.logdir }}
- user: {{ apache.user }}
- group: {{ apache.group }}
- recurse:
- user
- group
- makedirs: True
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
apache-config-file-directory-vhostdir:
file.directory:
- name: {{ apache.vhostdir }}
- makedirs: True
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
apache-config-file-directory-moddir:
file.directory:
- name: {{ apache.moddir }}
- makedirs: True
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
{%- if apache.davlockdbdir %}
apache-config-file-directory-davlockdbdir:
file.directory:
- name: {{ apache.davlockdbdir }}
- makedirs: True
- user: {{ apache.user }}
- group: {{ apache.group }}
- recurse:
- user
- group
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
{%- endif %}
{%- if 'sitesdir' in apache and apache.sitesdir %}
apache-config-file-directory-sites-enabled:
file.directory:
- name: {{ apache.sitesdir }}
- makedirs: True
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
{%- endif %}
{%- if grains.os_family in ('Debian',) and 'confdir' in apache and apache.confdir %}
apache-config-file-directory-conf-enabled:
file.directory:
- name: {{ apache.confdir }}
- makedirs: True
- require:
- sls: {{ sls_package_install }}
- require_in:
- service: apache-service-running
{%- endif %}
apache-config-file-managed:
file.managed:
- name: {{ apache.config }}
- source: 'salt://apache/files/{{ grains.os_family }}/apache-{{ apache.version }}.config.jinja'
- mode: 644
- user: {{ apache.rootuser }}
{%- if grains.kernel != 'Windows' %}
- group: {{ apache.rootgroup }}
{%- endif %}
- makedirs: True
- template: {{ apache.get('template_engine', 'jinja') }}
- require:
- sls: {{ sls_package_install }}
- context:
apache: {{ apache | json }}
{%- if grains.os_family in ('Debian', 'FreeBSD') %}
apache-config-file-managed-{{ grains.os }}-env:
file.managed:
- name: /etc/apache2/envvars
- source: 'salt://apache/files/{{ grains.os_family }}/envvars-{{ apache.version }}.jinja'
- mode: 644
- user: {{ apache.rootuser }}
- group: {{ apache.rootgroup }}
- makedirs: True
- template: {{ apache.get('template_engine', 'jinja') }}
- context:
apache: {{ apache | json }}
- require_in:
- file: apache-config-file-managed-{{ grains.os }}-ports
apache-config-file-managed-{{ grains.os }}-ports:
file.managed:
- name: {{ apache.portsfile }}
- source: salt://apache/files/{{ grains.os_family }}/ports-{{ apache.version }}.conf.jinja
- mode: 644
- user: {{ apache.rootuser }}
- group: {{ apache.rootgroup }}
- makedirs: True
- template: {{ apache.get('template_engine', 'jinja') }}
- context:
apache: {{ apache | json }}
{%- elif grains.os_family == "RedHat" %}
apache-config-file-absent-{{ grains.os }}:
file.absent:
- name: {{ apache.confdir }}/welcome.conf
{%- elif grains.os_family == "Suse" %}
apache-config-file-managed-{{ grains.os }}:
file.managed:
- name: /etc/apache2/global.conf
- source: 'salt://apache/files/Suse/global.config.jinja'
- mode: 644
- user: {{ apache.rootuser }}
- group: {{ apache.rootgroup }}
- makedirs: True
- template: {{ apache.get('template_engine', 'jinja') }}
- context:
apache: {{ apache | json }}
{%- else %}
apache-config-file-managed-skip:
test.show_notification:
- text: |
No configuration file to manage
{%- endif %}
- require:
- sls: {{ sls_package_install }}
- watch_in:
- module: apache-service-running-restart
- require_in:
- module: apache-service-running-restart
- service: apache-service-running