Merge "Adds Listen directive to openstack-dashboard vhost"
diff --git a/horizon/files/openstack-dashboard.conf.Debian b/horizon/files/openstack-dashboard.conf.Debian
index 224dccb..362bd4a 100644
--- a/horizon/files/openstack-dashboard.conf.Debian
+++ b/horizon/files/openstack-dashboard.conf.Debian
@@ -1,6 +1,12 @@
 {%- from "horizon/map.jinja" import server with context %}
+{%- set bind_port = server.get('bind',{}).get('port', 80) %}
+{%- set bind_host_port = server.get('bind', {}).get('address', '0.0.0.0') ~ ":" ~ bind_port %}
+{#- Apache listens on 80 and 443 by default in ports.conf, can't duplicate Listen declaration #}
+{%- if bind_port not in [80, 443] %}
+  Listen {{ bind_host_port }}
+{%- endif %}
 
-<VirtualHost {{ server.get('bind', {}).get('address', '0.0.0.0') }}:{{ server.get('bind', {}).get('port', 80) }}>
+<VirtualHost {{ bind_host_port }}>
   ServerName {{ server.get('host', {}).get('name', 'openstack-dashboard') }}
 
   WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
diff --git a/horizon/files/ports.conf b/horizon/files/ports.conf
deleted file mode 100644
index 3b7254e..0000000
--- a/horizon/files/ports.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-{%- from "horizon/map.jinja" import server with context %}
-# If you just change the port or add more ports here, you will likely also
-# have to change the VirtualHost statement in
-# /etc/apache2/sites-enabled/000-default.conf
-
-Listen {{ server.bind.address }}:{{ server.bind.port }}
-
-<IfModule ssl_module>
-        Listen {{ server.bind.address }}:443
-</IfModule>
-
-<IfModule mod_gnutls.c>
-        Listen {{ server.bind.address }}:443
-</IfModule>
-
-# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
diff --git a/horizon/map.jinja b/horizon/map.jinja
index 7fec03e..b5e5b07 100644
--- a/horizon/map.jinja
+++ b/horizon/map.jinja
@@ -19,8 +19,6 @@
         'apache_log_format': '%h %t %m \\"%U%q\\" %H %>s %O %D \\"%{Referer}i\\" \\"%{User-Agent}i\\"',
         'certs_dir': '/etc/ssl/certs',
         'private_dir': '/etc/ssl/private',
-        'port_config_file': '/etc/apache2/ports.conf',
-        'port_config_template': 'salt://horizon/files/ports.conf',
         'cache': {'host': '127.0.0.1', 'port': 11211}
     },
     'RedHat': {
diff --git a/horizon/server/service.sls b/horizon/server/service.sls
index e7fd51c..fa0ad5e 100644
--- a/horizon/server/service.sls
+++ b/horizon/server/service.sls
@@ -58,17 +58,6 @@
 
 {%- endfor %}
 
-horizon_apache_port_config:
-  file.managed:
-  - name: {{ server.port_config_file }}
-  - source: {{ server.port_config_template }}
-  - template: jinja
-  - mode: 644
-  - user: root
-  - group: root
-  - require:
-    - pkg: horizon_packages
-
 horizon_apache_config:
   file.managed:
   - name: {{ server.apache_config }}
@@ -101,7 +90,6 @@
     - file: horizon_config
     - file: horizon_apache_config
     - file: horizon_log_file
-    - file: horizon_apache_port_config
 
 horizon_log_dir:
   file.directory:
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
index 7240cdd..952413f 100644
--- a/tests/pillar/cluster.sls
+++ b/tests/pillar/cluster.sls
@@ -13,7 +13,7 @@
     cache:
       engine: memcached
       prefix: 'CACHE_HORIZON'
-      members: 
+      members:
       - host: 127.0.0.1
         port: 11211
       - host: 127.0.0.1