From 53f12d2f8053c0a4afe3f8fc3ef5006e453cc435 Mon Sep 17 00:00:00 2001 From: Eric Veiras Galisson Date: Wed, 18 Dec 2019 16:59:19 +0100 Subject: [PATCH] feat: config state now also managed rabbitmq env file --- pillar.example | 2 ++ rabbitmq/config.sls | 12 ++++++++++++ rabbitmq/files/rabbitmq-env.conf | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 rabbitmq/files/rabbitmq-env.conf diff --git a/pillar.example b/pillar.example index 319d11a2..79b8109a 100644 --- a/pillar.example +++ b/pillar.example @@ -3,6 +3,8 @@ rabbitmq: # version: "3.5.3-1" enabled: true running: true + env: + rabbitmq_mnesia_base: /opt/rabbitmq plugin: rabbitmq_management: - enabled diff --git a/rabbitmq/config.sls b/rabbitmq/config.sls index c63b7022..f7ee0216 100644 --- a/rabbitmq/config.sls +++ b/rabbitmq/config.sls @@ -46,3 +46,15 @@ rabbitmq_user_guest: rabbitmq_user.absent: - name: guest {% endif %} + +{%- if salt['pillar.get']('rabbitmq:env', None) %} +rabbitmq_env-file: + file.managed: + - name: /etc/rabbitmq/rabbitmq-env.conf + - source: salt://{{ slspath }}/files/rabbitmq-env.conf + - template: jinja + - context: + env: {{ salt['pillar.get']('rabbitmq:env', {}) }} + - watch_in: + - service: rabbitmq-server +{%- endif %} diff --git a/rabbitmq/files/rabbitmq-env.conf b/rabbitmq/files/rabbitmq-env.conf new file mode 100644 index 00000000..a941962b --- /dev/null +++ b/rabbitmq/files/rabbitmq-env.conf @@ -0,0 +1,8 @@ +######################################################################## +# File managed by Salt at <{{ source }}>. +# Your changes will be overwritten. +######################################################################## + +{% for key, value in env.items() %} +{{ key | upper }}={{ value }} +{%- endfor %}