Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3793800
D1855.id4682.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D1855.id4682.diff
View Options
diff --git a/_modules/paas_docker.py b/_modules/paas_docker.py
new file mode 100644
--- /dev/null
+++ b/_modules/paas_docker.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+# -------------------------------------------------------------
+# Salt — PaaS Docker execution module
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2018-10-07
+# Description: Functions related to data format conversions
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+def get_image(default_image, args):
+ """
+ A function to output a pillar key in JSON.
+
+ State Example::
+
+ {% image = salt['paas_docker.get_image']("nasqueron/mysql", container) %}
+ """
+ image = default_image
+
+ if 'image' in args:
+ image = args['image']
+
+ if 'version' in args:
+ image += ":" + args['version']
+
+ return image
diff --git a/_tests/modules/test_paas_docker.py b/_tests/modules/test_paas_docker.py
new file mode 100644
--- /dev/null
+++ b/_tests/modules/test_paas_docker.py
@@ -0,0 +1,33 @@
+from importlib.machinery import SourceFileLoader
+import unittest
+
+salt_test_case = SourceFileLoader('salt_test_case', "salt_test_case.py").load_module()
+docker = SourceFileLoader('docker', '../_modules/paas_docker.py').load_module()
+
+
+class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
+
+ def test_get_image(self):
+ container = {
+ "image": "foo",
+ "version": "42"
+ }
+
+ self.assertEqual("foo:42", docker.get_image("not_foo", container))
+
+ def test_get_image_without_version(self):
+ container = {
+ "image": "foo",
+ }
+
+ self.assertEqual("foo", docker.get_image("not_foo", container))
+
+ def test_get_image_without_image(self):
+ container = {
+ "version": "42"
+ }
+
+ self.assertEqual("not_foo:42", docker.get_image("not_foo", container))
+
+ def test_get_image_without_anything(self):
+ self.assertEqual("not_foo", docker.get_image("not_foo", {}))
diff --git a/pillar/paas/docker.sls b/pillar/paas/docker.sls
--- a/pillar/paas/docker.sls
+++ b/pillar/paas/docker.sls
@@ -24,6 +24,7 @@
dwellers:
# Core services
+ - nasqueron/mysql:5.7
- nasqueron/rabbitmq
# Infrastructure and development services
@@ -114,9 +115,16 @@
#
# Dwellers is the engine for Mastodon and CI intelligent bus services
#
-
dwellers:
- {}
+
+ #
+ # Core services
+ #
+
+ mysql:
+ bugzilla_db:
+ network: bugzilla
+ version: 5.7
#
# Equatower is the current production engine
diff --git a/roles/paas-docker/containers/mysql.sls b/roles/paas-docker/containers/mysql.sls
--- a/roles/paas-docker/containers/mysql.sls
+++ b/roles/paas-docker/containers/mysql.sls
@@ -9,7 +9,8 @@
{% set has_selinux = salt['grains.get']('selinux:enabled', False) %}
{% set containers = pillar['docker_containers'][grains['id']] %}
-{% for instance in containers['mysql'] %}
+{% for instance, container in containers['mysql'] %}
+{% set image = salt['paas_docker.get_image']("nasqueron/mysql", container) %}
# -------------------------------------------------------------
# Home directory
@@ -40,9 +41,12 @@
docker_container.running:
- detach: True
- interactive: True
- - image: nasqueron/mysql
+ - image: {{ image }}
- binds: /srv/{{ instance }}/mysql:/var/lib/mysql
- environment:
MYSQL_ROOT_PASSWORD: {{ salt['random.get_str'](31) }}
-
+{% if 'network' in container %}
+ - networks:
+ - {{ container['network'] }}
+{% endif %}
{% endfor %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 21:27 (16 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2269988
Default Alt Text
D1855.id4682.diff (3 KB)
Attached To
Mode
D1855: Deploy a MySQL 5.7 container for Bugzilla
Attached
Detach File
Event Timeline
Log In to Comment