diff --git a/README.rst b/README.rst index 74d9d51..b207a42 100644 --- a/README.rst +++ b/README.rst @@ -55,6 +55,11 @@ Enables the Apache module mod_proxy. (Debian and FreeBSD only) Enables the Apache module mod_proxy_http and requires the Apache module mod_proxy to be enabled. (Debian Only) +``apache.mod_proxy_fcgi`` +------------------------- + +Enables the Apache module mod_proxy_fcgi and requires the Apache module mod_proxy to be enabled. (Debian Only) + ``apache.mod_wsgi`` ------------------- @@ -100,6 +105,11 @@ Enables mod_cgi. (FreeBSD only) Installs and enables the mod_fcgid module +``apache.mod_fastcgi`` +-------------------- + +Installs and enables the mod_fastcgi module + ``apache.mod_dav_svn`` -------------------- @@ -144,6 +154,11 @@ Enables the Apache module vhost_alias (Debian Only) Enables and configures the Apache module mod_remoteip using data from Pillar. (Debian Only) +``apache.mod_xsendfile`` +---------------------- + +Installs and enables mod_xsendfile module. (Debian Only) + ``apache.own_default_vhost`` -------------------------- @@ -188,6 +203,11 @@ Configures Apache's security.conf options by reassinging them using data from Pi Installs and configures Apache on Debian and Ubuntu systems. +``apache.uninstall`` +---------- + +Stops the Apache service and uninstalls the package. + These states are ordered using the ``order`` declaration. Different stages are divided into the following number ranges: diff --git a/apache/config.sls b/apache/config.sls index 4691f8e..6a29683 100644 --- a/apache/config.sls +++ b/apache/config.sls @@ -17,6 +17,7 @@ include: {{ apache.vhostdir }}: file.directory: + - makedirs: True - require: - pkg: apache - watch_in: diff --git a/apache/map.jinja b/apache/map.jinja index 7dcd50c..70d4b43 100644 --- a/apache/map.jinja +++ b/apache/map.jinja @@ -35,6 +35,8 @@ 'mod_perl2': 'libapache2-mod-perl2', 'mod_fcgid': 'libapache2-mod-fcgid', 'mod_pagespeed_source': 'https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb', + 'mod_xsendfile': 'libapache2-mod-xsendfile', + 'mod_fastcgi': 'libapache2-mod-fastcgi', 'vhostdir': '/etc/apache2/sites-available', 'confdir': '/etc/apache2/conf.d', @@ -54,6 +56,7 @@ 'configfile': '/etc/httpd/conf/httpd.conf', 'mod_wsgi': 'mod_wsgi', + 'conf_mod_wsgi': '/etc/httpd/conf.d/wsgi.conf', 'mod_php5': 'php', 'mod_pagespeed_source': 'https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm', diff --git a/apache/mod_fastcgi.sls b/apache/mod_fastcgi.sls new file mode 100644 index 0000000..36e8e7e --- /dev/null +++ b/apache/mod_fastcgi.sls @@ -0,0 +1,32 @@ +{% from "apache/map.jinja" import apache with context %} + +include: + - apache + - apache.mod_actions + +{% if grains['os_family']=="Debian" %} +mod-fastcgi: + pkg.installed: + - name: {{ apache.mod_fastcgi }} + - order: 180 + - require: + - pkgrepo: repo-fastcgi + - pkg: apache + +repo-fastcgi: + pkgrepo.managed: + - name: "deb http://httpredir.debian.org/debian jessie" + - file: /etc/apt/sources.list.d/non-free.list + - comps: non-free + +a2enmod fastcgi: + cmd.run: + - unless: ls /etc/apache2/mods-enabled/fastcgi.load + - order: 225 + - require: + - pkg: mod-fastcgi + - watch_in: + - module: apache-restart + +{% endif %} + diff --git a/apache/mod_proxy_fcgi.sls b/apache/mod_proxy_fcgi.sls new file mode 100644 index 0000000..d95d1ed --- /dev/null +++ b/apache/mod_proxy_fcgi.sls @@ -0,0 +1,17 @@ +{% if grains['os_family']=="Debian" %} + +include: + - apache + - apache.mod_proxy + +a2enmod proxy_fcgi: + cmd.run: + - unless: ls /etc/apache2/mods-enabled/proxy_fcgi.load + - order: 225 + - require: + - pkg: apache + - cmd: a2enmod proxy + - watch_in: + - module: apache-restart + +{% endif %} diff --git a/apache/mod_wsgi.sls b/apache/mod_wsgi.sls index 73f9251..aa3fd21 100644 --- a/apache/mod_wsgi.sls +++ b/apache/mod_wsgi.sls @@ -9,10 +9,11 @@ mod_wsgi: - require: - pkg: apache -{% if grains.get('os_family') == 'RedHat' %} -/etc/httpd/conf.d/wsgi.conf: +{% if apache.conf_mod_wsgi %} +{{ apache.conf_mod_wsgi }}: file.uncomment: - regex: LoadModule + - onlyif: test -f {{ apache.conf_mod_wsgi }} - require: - pkg: mod_wsgi {% endif %} diff --git a/apache/mod_xsendfile.sls b/apache/mod_xsendfile.sls new file mode 100644 index 0000000..e86f075 --- /dev/null +++ b/apache/mod_xsendfile.sls @@ -0,0 +1,24 @@ +{% from "apache/map.jinja" import apache with context %} + +include: + - apache + +mod-xsendfile: + pkg.installed: + - name: {{ apache.mod_xsendfile }} + - order: 180 + - require: + - pkg: apache + +{% if grains['os_family']=="Debian" %} +a2enmod xsendfile: + cmd.run: + - order: 225 + - unless: ls /etc/apache2/mods-enabled/xsendfile.load + - require: + - pkg: mod-xsendfile + - watch_in: + - module: apache-restart + +{% endif %} + diff --git a/apache/osfingermap.yaml b/apache/osfingermap.yaml index abef80b..27873ec 100644 --- a/apache/osfingermap.yaml +++ b/apache/osfingermap.yaml @@ -6,10 +6,11 @@ Red Hat Enterprise Linux Server-6: version: '2.2' Red Hat Enterprise Linux Server-7: version: '2.4' -CentOS Linux-6: +CentOS-6: version: '2.2' CentOS Linux-7: version: '2.4' + conf_mod_wsgi: '/etc/httpd/conf.modules.d/10-wsgi.conf' Oracle Linux Server-6: version: '2.2' Oracle Linux Server-7: diff --git a/apache/vhosts/minimal.tmpl b/apache/vhosts/minimal.tmpl new file mode 100644 index 0000000..d2243c7 --- /dev/null +++ b/apache/vhosts/minimal.tmpl @@ -0,0 +1,30 @@ +{# Define default values here so the template below can just focus on layout #} +{%- set sitename = site.get('ServerName', id) -%} + +{%- set vals = { + 'interfaces': site.get('interface', '*').split(), + 'port': site.get('port', '80'), + + 'ServerName': sitename, + 'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)), + + 'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)), + + 'LogLevel': site.get('LogLevel', 'warn'), + 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)), + 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), + + 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)) +} -%} + + + ServerName {{ vals.ServerName }} + {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} + {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %} + + {% if site.get('DocumentRoot') != False -%}DocumentRoot {{ vals.DocumentRoot }}{% endif %} + + {% if site.get('LogLevel') != False -%}LogLevel {{ vals.LogLevel }}{% endif %} + {% if site.get('ErrorLog') != False -%}ErrorLog {{ vals.ErrorLog }}{% endif %} + {% if site.get('CustomLog') != False -%}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %} + diff --git a/pillar.example b/pillar.example index 17539bc..8969a2c 100644 --- a/pillar.example +++ b/pillar.example @@ -41,7 +41,7 @@ apache: example.com: # must be unique; used as an ID declaration in Salt. enabled: True - template_file: salt://apache/vhosts/standard.tmpl # or redirect.tmpl or proxy.tmpl + template_file: salt://apache/vhosts/standard.tmpl # or minimal.tmpl or redirect.tmpl or proxy.tmpl ####################### DEFAULT VALUES BELOW ############################ # NOTE: the values below are simply default settings that *can* be