Merge "Implement X.509 auth for MySQL and Glance"
diff --git a/galera/server/database/ssl/glance.yml b/galera/server/database/ssl/glance.yml
new file mode 100644
index 0000000..99802f8
--- /dev/null
+++ b/galera/server/database/ssl/glance.yml
@@ -0,0 +1,4 @@
+parameters:
+  _param:
+    mysql_glance_ssl_option:
+      - SSL: True
\ No newline at end of file
diff --git a/galera/server/database/x509/glance.yml b/galera/server/database/x509/glance.yml
new file mode 100644
index 0000000..2fdcea3
--- /dev/null
+++ b/galera/server/database/x509/glance.yml
@@ -0,0 +1,7 @@
+parameters:
+  _param:
+    mysql_glance_client_ssl_x509_subject: '/C=cz/CN=mysql-glance-client/L=Prague/O=Mirantis'
+    mysql_glance_client_ssl_x509_issuer: '/C=cz/CN=Salt Master CA/L=Prague/O=Mirantis'
+    mysql_glance_ssl_option:
+      - SUBJECT: ${_param:mysql_glance_client_ssl_x509_subject}
+      - ISSUER: ${_param:mysql_glance_client_ssl_x509_issuer}
\ No newline at end of file
diff --git a/glance/control/cluster.yml b/glance/control/cluster.yml
index ae2b3c1..a9181de 100644
--- a/glance/control/cluster.yml
+++ b/glance/control/cluster.yml
@@ -3,7 +3,11 @@
 - service.keepalived.cluster.single
 - service.haproxy.proxy.single
 - system.haproxy.proxy.listen.openstack.glance
+- system.salt.minion.cert.mysql.clients.openstack.glance
 parameters:
+  _param:
+    openstack_mysql_x509_enabled: False
+    galera_ssl_enabled: False
   linux:
     system:
       cron:
@@ -27,6 +31,13 @@
         name: glance
         user: glance
         password: ${_param:mysql_glance_password}
+        x509:
+          enabled: ${_param:openstack_mysql_x509_enabled}
+          ca_file: ${_param:mysql_glance_ssl_ca_file}
+          key_file: ${_param:mysql_glance_client_ssl_key_file}
+          cert_file: ${_param:mysql_glance_client_ssl_cert_file}
+        ssl:
+          enabled: ${_param:galera_ssl_enabled}
       registry:
         host: ${_param:cluster_vip_address}
         port: 9191
diff --git a/glance/control/single.yml b/glance/control/single.yml
index cd5a6fe..a036077 100644
--- a/glance/control/single.yml
+++ b/glance/control/single.yml
@@ -1,6 +1,10 @@
 classes:
 - service.glance.control.single
+- system.salt.minion.cert.mysql.clients.openstack.glance
 parameters:
+  _param:
+    openstack_mysql_x509_enabled: False
+    galera_ssl_enabled: False
   linux:
     system:
       cron:
@@ -16,6 +20,13 @@
       role: ${_param:openstack_node_role}
       database:
         host: ${_param:single_address}
+        x509:
+          enabled: ${_param:openstack_mysql_x509_enabled}
+          ca_file: ${_param:mysql_glance_ssl_ca_file}
+          key_file: ${_param:mysql_glance_client_ssl_key_file}
+          cert_file: ${_param:mysql_glance_client_ssl_cert_file}
+        ssl:
+          enabled: ${_param:galera_ssl_enabled}
       identity:
         region: ${_param:openstack_region}
       show_multiple_locations: True
diff --git a/salt/minion/cert/mysql/clients/openstack/glance.yml b/salt/minion/cert/mysql/clients/openstack/glance.yml
new file mode 100644
index 0000000..ab71174
--- /dev/null
+++ b/salt/minion/cert/mysql/clients/openstack/glance.yml
@@ -0,0 +1,27 @@
+parameters:
+  _param:
+    salt_minion_ca_host: cfg01.${_param:cluster_domain}
+    salt_minion_ca_authority: salt_master_ca
+    mysql_glance_client_ssl_key_file: /etc/glance/ssl/mysql/client-key.pem
+    mysql_glance_client_ssl_cert_file: /etc/glance/ssl/mysql/client-cert.pem
+    mysql_glance_ssl_ca_file: /etc/glance/ssl/mysql/ca-cert.pem
+  salt:
+    minion:
+      cert:
+        mysql-glance-client:
+          host: ${_param:salt_minion_ca_host}
+          authority: ${_param:salt_minion_ca_authority}
+          common_name: mysql-glance-client
+          signing_policy: cert_client
+          alternative_names: >
+            IP:${_param:cluster_local_address},
+            DNS:${_param:cluster_local_address},
+            DNS:${linux:system:name},
+            DNS:${linux:network:fqdn}
+          key_usage: "digitalSignature,nonRepudiation,keyEncipherment"
+          key_file: ${_param:mysql_glance_client_ssl_key_file}
+          cert_file: ${_param:mysql_glance_client_ssl_cert_file}
+          ca_file: ${_param:mysql_glance_ssl_ca_file}
+          user: glance
+          group: glance
+          mode: 640