Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3775465
D2968.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2968.id.diff
View Options
diff --git a/_modules/paas_docker.py b/_modules/paas_docker.py
--- a/_modules/paas_docker.py
+++ b/_modules/paas_docker.py
@@ -91,6 +91,20 @@
]
+# -------------------------------------------------------------
+# Nginx
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def resolve_vhost_config_file(service, dir="roles/paas-docker/nginx/files/vhosts"):
+ candidate = f"{dir}/{service}.conf"
+
+ if __salt__["slsutil.file_exists"](candidate):
+ return candidate
+
+ return f"{dir}/_default.conf"
+
+
# -------------------------------------------------------------
# Monitoring
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/_tests/data/empty.conf b/_tests/data/empty.conf
new file mode 100644
diff --git a/_tests/modules/test_paas_docker.py b/_tests/modules/test_paas_docker.py
--- a/_tests/modules/test_paas_docker.py
+++ b/_tests/modules/test_paas_docker.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from importlib.machinery import SourceFileLoader
+import os
import unittest
salt_test_case = SourceFileLoader("salt_test_case", "salt_test_case.py").load_module()
@@ -17,6 +18,9 @@
self.mock_grains()
self.grains["id"] = "egladil"
+ self.mock_salt()
+ self.salt["slsutil.file_exists"] = lambda file: os.path.exists(file)
+
def test_get_image(self):
container = {"image": "foo", "version": "42"}
@@ -47,6 +51,16 @@
self.assertEqual("foo:2.5", docker.get_image("not_foo", container))
+ def test_resolve_vhost_config_file(self):
+ config_file = docker.resolve_vhost_config_file("empty", dir="data")
+
+ self.assertEqual("data/empty.conf", config_file)
+
+ def test_resolve_vhost_config_file_when_not_existing(self):
+ config_file = docker.resolve_vhost_config_file("foo", dir="notexisting")
+
+ self.assertEqual("notexisting/_default.conf", config_file)
+
def test_get_subnets(self):
expected = ["172.18.1.0/24", "172.18.2.0/24", "172.17.0.0/16"]
diff --git a/roles/paas-docker/nginx/config.sls b/roles/paas-docker/nginx/config.sls
--- a/roles/paas-docker/nginx/config.sls
+++ b/roles/paas-docker/nginx/config.sls
@@ -66,9 +66,11 @@
{% for instance, container in instances.items() %}
{% if 'host' in container %}
+{% set vhost_config = salt["paas_docker.resolve_vhost_config_file"](service) %}
+
{{ dirs.etc }}/nginx/vhosts/{{ service }}/{{ instance }}.conf:
file.managed:
- - source: salt://roles/paas-docker/nginx/files/vhosts/{{ service }}.conf
+ - source: salt://{{ vhost_config }}
- mode: 644
- makedirs: True
- template: jinja
diff --git a/roles/paas-docker/nginx/files/vhosts/hound.conf b/roles/paas-docker/nginx/files/vhosts/hound.conf
deleted file mode 100644
--- a/roles/paas-docker/nginx/files/vhosts/hound.conf
+++ /dev/null
@@ -1 +0,0 @@
-{% include 'roles/paas-docker/nginx/files/vhosts/_default.conf' %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 18:46 (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262662
Default Alt Text
D2968.id.diff (2 KB)
Attached To
Mode
D2968: Allow to use _default.conf for PaaS Docker nginx vhost
Attached
Detach File
Event Timeline
Log In to Comment