Skip to content

Instantly share code, notes, and snippets.

@SEJeff
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SEJeff/f23aba36a200a66a858e to your computer and use it in GitHub Desktop.
Save SEJeff/f23aba36a200a66a858e to your computer and use it in GitHub Desktop.
States for reproducing salt bug #14497. They are all under services/httpd/ in the states tree
{% from "services/httpd/map.jinja" import httpd with context %}
{% set ltsv_conf = httpd.modconfdir + "/00-ltsv-log-format.conf" %}
httpd:
pkg:
- installed
- name: {{ httpd.pkg }}
service:
- running
- name: {{ httpd.service }}
- enable: true
- watch:
# reload apache when this file changes
- file: {{ ltsv_conf }}
# Always throw down the config enabling ltsv_extended LogFormat
{{ ltsv_conf }}:
file.managed:
- template: jinja
- source: salt://services/httpd/files/ltsv-log-format.conf.jinja
# On RHEL7 and Fedora 18+, we're using Apache 2.4, so put module
# configuration under the modules directory and set a version variable
# for the configuration templates to key off of
#
# The varname|default('blah') syntax is a jinja trick, see:
# http://jinja.pocoo.org/docs/templates/#default
{% if grains['os_family'] == 'RedHat' %}
{% if grains['os'] == 'RedHat' and grains['osmajorrelease'][0] >= 7 %}
{% set mod_conf_dir = '/etc/httpd/conf.modules.d' %}
{% set version = 2.4 %}
{% elif grains['os'] == 'Fedora' and grains[osmajorrelease][0] >= 18 %}
{% set mod_conf_dir = '/etc/httpd/conf.modules.d' %}
{% set version = 2.4 %}
{% endif %}
{% endif %}
{% set httpd = salt['grains.filter_by']({
'Debian': {
'pkg': 'apache2',
'service': 'apache2',
'user': 'www-data',
'mod_wsgi': 'libapache2-mod-wsgi',
'mod_ssl': 'apache2.2-bin',
'certdir': '/etc/ssl/private',
'vhostdir': '/etc/apache2/sites-available',
'confdir': '/etc/apache2/conf.d',
'modconfdir': mod_conf_dir|default('/etc/apache2/conf.d'),
'logdir': '/var/log/apache2',
'wwwdir': '/srv',
'version': version|default(2.2),
},
'RedHat': {
'pkg': 'httpd',
'service': 'httpd',
'user': 'apache',
'mod_wsgi': 'mod_wsgi',
'mod_ssl': 'mod_ssl',
'certdir': '/etc/pki/tls/certs',
'vhostdir': '/etc/httpd/conf.d',
'confdir': '/etc/httpd/conf.d',
'modconfdir': mod_conf_dir|default('/etc/httpd/conf.d'),
'logdir': '/var/log/httpd',
'wwwdir': '/var/www',
'version': version|default(2.2),
},
}, merge=salt['pillar.get']('httpd:lookup')) %}
{% from "services/httpd/map.jinja" import httpd with context %}
####### THIS IS BROKEN #######
include:
- .httpd
##### END THIS IS BROKEN #####
# This works
#include:
# - services.httpd
# Install the package containing ssl in a cross distro
# manner and ensure to restart the service when done.
{{ httpd.mod_ssl }}:
pkg.installed:
- watch_in:
- service: {{ httpd.service }}
# Default ssl certificate WAT!?
{% for file in ('wildcard1.crt', 'wildcard1.key',) %}
{{ httpd.certdir }}/{{ file }}:
file.managed:
- source: salt://services/httpd/files/{{ file }}
- mode: 0640
- makedirs: true
# Refresh the httpd service when this file changes
- watch_in:
- service: {{ httpd.service }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment