Implement X.509 auth between Rabbitmq and Keystone
Change-Id: Ib1b37cbc60f40422e8960173f05bf926dfb6b580
Relaited-Prod: PROD-22763
diff --git a/keystone/_ssl/rabbitmq.sls b/keystone/_ssl/rabbitmq.sls
new file mode 100644
index 0000000..7169696
--- /dev/null
+++ b/keystone/_ssl/rabbitmq.sls
@@ -0,0 +1,79 @@
+{%- from "keystone/map.jinja" import server with context %}
+
+keystone_ssl_rabbitmq:
+ test.show_notification:
+ - text: "Running keystone._ssl.rabbitmq"
+
+{%- if server.notification %}
+ {%- if server.message_queue.get('x509',{}).get('enabled',False) %}
+
+ {%- set ca_file=server.message_queue.x509.ca_file %}
+ {%- set key_file=server.message_queue.x509.key_file %}
+ {%- set cert_file=server.message_queue.x509.cert_file %}
+
+rabbitmq_keystone_ssl_x509_ca:
+ {%- if server.message_queue.x509.cacert is defined %}
+ file.managed:
+ - name: {{ ca_file }}
+ - contents_pillar: keystone:server:message_queue:x509:cacert
+ - mode: 444
+ - user: keystone
+ - group: keystone
+ - makedirs: true
+ {%- else %}
+ file.exists:
+ - name: {{ ca_file }}
+ {%- endif %}
+
+rabbitmq_keystone_client_ssl_cert:
+ {%- if server.message_queue.x509.cert is defined %}
+ file.managed:
+ - name: {{ cert_file }}
+ - contents_pillar: keystone:server:message_queue:x509:cert
+ - mode: 440
+ - user: keystone
+ - group: keystone
+ - makedirs: true
+ {%- else %}
+ file.exists:
+ - name: {{ cert_file }}
+ {%- endif %}
+
+rabbitmq_keystone_client_ssl_private_key:
+ {%- if server.message_queue.x509.key is defined %}
+ file.managed:
+ - name: {{ key_file }}
+ - contents_pillar: keystone:server:message_queue:x509:key
+ - mode: 400
+ - user: keystone
+ - group: keystone
+ - makedirs: true
+ {%- else %}
+ file.exists:
+ - name: {{ key_file }}
+ {%- endif %}
+
+rabbitmq_keystone_ssl_x509_set_user_and_group:
+ file.managed:
+ - names:
+ - {{ ca_file }}
+ - {{ cert_file }}
+ - {{ key_file }}
+ - user: keystone
+ - group: keystone
+
+ {% elif server.message_queue.get('ssl',{}).get('enabled',False) %}
+rabbitmq_ca_keystone_client:
+ {%- if server.message_queue.ssl.cacert is defined %}
+ file.managed:
+ - name: {{ server.message_queue.ssl.cacert_file }}
+ - contents_pillar: keystone:server:message_queue:ssl:cacert
+ - mode: 0444
+ - makedirs: true
+ {%- else %}
+ file.exists:
+ - name: {{ server.message_queue.ssl.get('cacert_file', server.cacert_file) }}
+ {%- endif %}
+
+ {%- endif %}
+{%- endif %}
diff --git a/keystone/files/pike/keystone.conf.Debian b/keystone/files/pike/keystone.conf.Debian
index 29f69d9..760240b 100644
--- a/keystone/files/pike/keystone.conf.Debian
+++ b/keystone/files/pike/keystone.conf.Debian
@@ -1975,18 +1975,25 @@
{%- if server.notification %}
-{%- if server.message_queue.get('ssl',{}).get('enabled', False) %}
+ {%- if server.message_queue.get('ssl',{}).get('enabled', False) %}
rabbit_use_ssl=true
-{%- if server.message_queue.ssl.version is defined %}
+ {%- if server.message_queue.ssl.version is defined %}
kombu_ssl_version = {{ server.message_queue.ssl.version }}
-{%- elif salt['grains.get']('pythonversion') > [2,7,8] %}
+ {%- elif salt['grains.get']('pythonversion') > [2,7,8] %}
kombu_ssl_version = TLSv1_2
-{%- endif %}
+ {%- endif %}
+
+ {%- if server.message_queue.get('x509',{}).get('enabled', False) %}
+kombu_ssl_ca_certs = {{ server.message_queue.x509.ca_file}}
+kombu_ssl_keyfile = {{ server.message_queue.x509.key_file}}
+kombu_ssl_certfile = {{ server.message_queue.x509.cert_file}}
+ {%- else %}
kombu_ssl_ca_certs = {{ server.message_queue.ssl.get('cacert_file', server.cacert_file) }}
-{%- endif %}
+ {%- endif %}
+ {%- endif %}
{%- endif %}
# Use durable queues in AMQP. (boolean value)
diff --git a/keystone/server.sls b/keystone/server.sls
index b28d8a6..27985ee 100644
--- a/keystone/server.sls
+++ b/keystone/server.sls
@@ -8,13 +8,14 @@
{%- endif %}
- keystone.db.offline_sync
- keystone._ssl.mysql
-
+ - keystone._ssl.rabbitmq
keystone_packages:
pkg.installed:
- names: {{ server.pkgs }}
- require_in:
- sls: keystone.db.offline_sync
- sls: keystone._ssl.mysql
+ - sls: keystone._ssl.rabbitmq
{%- if server.service_name in ['apache2', 'httpd'] %}
- pkg: apache_packages
{%- endif %}
@@ -101,6 +102,7 @@
- require:
- pkg: keystone_packages
- sls: keystone._ssl.mysql
+ - sls: keystone._ssl.rabbitmq
- require_in:
- sls: keystone.db.offline_sync
- watch_in:
@@ -130,6 +132,7 @@
- require:
- pkg: keystone_packages
- sls: keystone._ssl.mysql
+ - sls: keystone._ssl.rabbitmq
- require_in:
- sls: keystone.db.offline_sync
- watch_in:
@@ -158,6 +161,7 @@
- require:
- pkg: keystone_packages
- sls: keystone._ssl.mysql
+ - sls: keystone._ssl.rabbitmq
{%- if server.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
- pkg: keystone_fluentd_logger_package
{%- endif %}