Browse Source

Merge pull request #113 from genuss/fix_listen

Manage ports.conf file properly
master
Forrest 9 years ago
parent
commit
2320295d09
9 changed files with 52 additions and 17 deletions
  1. +13
    -0
      apache/config.sls
  2. +0
    -5
      apache/debian_full.sls
  3. +7
    -0
      apache/files/Debian/apache-2.4.config.jinja
  4. +30
    -0
      apache/files/Debian/ports-2.4.conf.jinja
  5. +1
    -0
      apache/map.jinja
  6. +0
    -4
      apache/vhosts/proxy.tmpl
  7. +0
    -4
      apache/vhosts/redirect.tmpl
  8. +1
    -0
      apache/vhosts/standard.sls
  9. +0
    -4
      apache/vhosts/standard.tmpl

+ 13
- 0
apache/config.sls View File

- pkg: apache - pkg: apache
- watch_in: - watch_in:
- service: apache - service: apache

{{ apache.portsfile }}:
file.managed:
- template: jinja
- source:
- salt://apache/files/{{ salt['grains.get']('os_family') }}/ports-{{ apache.version }}.conf.jinja
- require:
- pkg: apache
- watch_in:
- service: apache
- context:
apache: {{ apache }}

{% endif %} {% endif %}


{% if grains['os_family']=="RedHat" %} {% if grains['os_family']=="RedHat" %}

+ 0
- 5
apache/debian_full.sls View File

- require: - require:
- pkg: apache - pkg: apache


/etc/apache2/ports.conf:
file.absent:
- require:
- pkg: apache

{% endif %} #END: os = debian {% endif %} #END: os = debian

+ 7
- 0
apache/files/Debian/apache-2.4.config.jinja View File

# together by including all remaining configuration files when starting up the # together by including all remaining configuration files when starting up the
# web server. # web server.
# #
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules, # directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations, # global configuration fragments, or virtual host configurations,
IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf IncludeOptional mods-enabled/*.conf


# Include list of ports to listen on
Include ports.conf



# Sets the default security model of the Apache2 HTTPD server. It does # Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www. # not allow access to the root filesystem outside of /usr/share and /var/www.

+ 30
- 0
apache/files/Debian/ports-2.4.conf.jinja View File

{%- from "apache/map.jinja" import apache with context -%}

# Managed by saltstack

{% if salt['pillar.get']('apache:sites') is mapping %}
{%- set listen_directives = [] %}
{%- for id, site in salt['pillar.get']('apache:sites').items() %}
{%- set interfaces = site.get('interface', '*').split() %}
{%- set port = site.get('port', 80) %}
{%- for interface in interfaces %}
{%- set listen_directive = interface ~ ':' ~ port %}
{%- if listen_directive not in listen_directives %}
{%- do listen_directives.append(listen_directive) %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for listen in listen_directives %}
Listen {{ listen }}
{%- endfor %}
{%- else %}
Listen 80

<IfModule mod_ssl.c>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>
{%- endif %}

+ 1
- 0
apache/map.jinja View File

'server': 'apache2', 'server': 'apache2',
'service': 'apache2', 'service': 'apache2',
'configfile': '/etc/apache2/apache2.conf', 'configfile': '/etc/apache2/apache2.conf',
'portsfile': '/etc/apache2/ports.conf',


'mod_wsgi': 'libapache2-mod-wsgi', 'mod_wsgi': 'libapache2-mod-wsgi',
'mod_php5': 'libapache2-mod-php5', 'mod_php5': 'libapache2-mod-php5',

+ 0
- 4
apache/vhosts/proxy.tmpl View File

'ProxyRoute': site.get('ProxyRoute', {}), 'ProxyRoute': site.get('ProxyRoute', {}),
} %} } %}


{% for intf in vals.interfaces -%}
Listen {{ intf }}:{{ vals.port }}
{% endfor %}

<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> <VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
ServerName {{ vals.ServerName }} ServerName {{ vals.ServerName }}
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}

+ 0
- 4
apache/vhosts/redirect.tmpl View File



} %} } %}


{% for intf in vals.interfaces -%}
Listen {{ intf }}:{{ vals.port }}
{% endfor %}

<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> <VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
ServerName {{ vals.ServerName }} ServerName {{ vals.ServerName }}
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}

+ 1
- 0
apache/vhosts/standard.sls View File



include: include:
- apache - apache
- apache.config


{% for id, site in salt['pillar.get']('apache:sites', {}).items() %} {% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, id)) %} {% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, id)) %}

+ 0
- 4
apache/vhosts/standard.tmpl View File

}, },
} -%} } -%}


{% for intf in vals.interfaces -%}
Listen {{ intf }}:{{ vals.port }}
{% endfor %}

<VirtualHost {% for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> <VirtualHost {% for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
ServerName {{ vals.ServerName }} ServerName {{ vals.ServerName }}
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}

Loading…
Cancel
Save