Skip to content

Commit

Permalink
fix(config): fix various configuration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 30, 2021
1 parent 7a169c0 commit f090d31
Show file tree
Hide file tree
Showing 30 changed files with 619 additions and 680 deletions.
24 changes: 12 additions & 12 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ rabbitmq:
## note : dict format
user: saltstack_mq
passwd: password
durable: true
auto_delete: false
durable: 'true'
auto_delete: 'false'
vhost: default_vhost
arguments:
- x-message-ttl: 8640000
- x-expires: 8640000
- x-dead-letter-exchange: my-exchange
bindings:
my-binding:
source: 'customers.direct'
source: 'amq.topic'
destination_type: queue
destination: my-queue
routing_key: a_routing_key_string
Expand All @@ -51,9 +51,9 @@ rabbitmq:
user: saltstack_mq
passwd: 'password'
type: fanout
durable: true
internal: false
auto_delete: false
durable: 'true'
internal: 'false'
auto_delete: 'false'
vhost: default_vhost
arguments:
- 'alternate-**exchange': 'amq.fanout'
Expand Down Expand Up @@ -135,16 +135,16 @@ rabbitmq:
## note : dict format
user: saltstack_mq
passwd: password
durable: true
auto_delete: false
durable: 'true'
auto_delete: 'false'
vhost: rabbit2_vhost
arguments:
- x-message-ttl: 8640000
- x-expires: 8640000
- x-dead-letter-exchange: my-exchange
bindings:
my-binding:
source: 'customers.direct'
source: 'amq.topic'
destination_type: queue
destination: my-queue
routing_key: a_routing_key_string
Expand All @@ -156,9 +156,9 @@ rabbitmq:
user: saltstack_mq
passwd: 'password'
type: fanout
durable: true
internal: false
auto_delete: false
durable: 'true'
internal: 'false'
auto_delete: 'false'
vhost: rabbit2_vhost
arguments:
- 'alternate-**exchange': 'amq.fanout'
Expand Down
6 changes: 2 additions & 4 deletions rabbitmq/config/bindings/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %}
{%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %}
{%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %}
include:
- {{ sls_service_clean }}
- {{ sls_config_plugins_clean }}
- {{ sls_config_users_clean }}
- {{ sls_config_vhosts_clean }}
Expand All @@ -20,13 +18,13 @@ include:
rabbitmq-config-bindings-delete-{{ name }}-{{ binding }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} delete binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} || true # noqa 204
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} || true # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
- test -d {{ rabbitmq.dir.data }}
# /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require_in:
- sls: {{ sls_service_clean }}
- sls: {{ sls_config_plugins_clean }}
- sls: {{ sls_config_users_clean }}
- sls: {{ sls_config_vhosts_clean }}
Expand Down
9 changes: 4 additions & 5 deletions rabbitmq/config/bindings/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %}
{%- set sls_config_users = tplroot ~ '.config.users.install' %}
{%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %}
include:
- {{ sls_service_running }}
- {{ sls_config_plugins }}
- {{ sls_config_users }}
- {{ sls_config_vhosts }}
Expand All @@ -20,11 +18,12 @@ include:
rabbitmq-config-bindings-enabled-{{ name }}-{{ binding }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} declare binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} routing_key={{ b.routing_key }} # noqa 204
- onlyif: test -x /usr/sbin/rabbitmqctl
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} routing_key={{ b.routing_key }} # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
- /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require:
- service: rabbitmq-service-running-service-running-{{ name }}
- sls: {{ sls_config_plugins }}
- sls: {{ sls_config_users }}
- sls: {{ sls_config_vhosts }}
Expand Down
8 changes: 3 additions & 5 deletions rabbitmq/config/exchanges/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %}
{%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %}
{%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %}
include:
- {{ sls_service_clean }}
- {{ sls_config_plugins_clean }}
- {{ sls_config_users_clean }}
- {{ sls_config_vhosts_clean }}
Expand All @@ -20,16 +18,16 @@ include:
rabbitmq-config-exchanges-delete-{{ name }}-{{ exchange }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} delete exchange --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ exchange }} || true # noqa 204
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete exchange --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ exchange }} || true # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
- test -d {{ rabbitmq.dir.data }}
- /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require_in:
- {{ sls_service_clean }}
- {{ sls_config_plugins_clean }}
- {{ sls_config_users_clean }}
- {{ sls_config_vhosts_clean }}
- {{ sls_config_plugins_clean }}
{%- endfor %}
{%- endif %}
Expand Down
15 changes: 10 additions & 5 deletions rabbitmq/config/exchanges/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %}
{%- set sls_config_users = tplroot ~ '.config.users.install' %}
{%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %}
include:
- {{ sls_service_running }}
- {{ sls_config_plugins }}
- {{ sls_config_users }}
- {{ sls_config_vhosts }}
{%- for name, node in rabbitmq.nodes.items() %}
{%- if 'exchanges' in node and node.exchanges is mapping %}
{%- for exchange, ex in node.exchanges.items() %}
rabbitmq-config-exchanges-enabled-{{ name }}-{{ exchange }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} declare exchange --vhost={{ ex.vhost }} --username={{ ex.user }} --password={{ ex.passwd }} name={{ exchange }} type={{ ex.type }} durable={{ ex.durable }} internal={{ ex.internal }} auto_delete={{ ex.auto_delete }} # noqa 204
- onlyif: test -x /usr/sbin/rabbitmqctl
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare exchange --vhost={{ ex.vhost }} --username={{ ex.user }} --password={{ ex.passwd }} name={{ exchange }} type={{ ex.type }} durable={{ ex.durable }} internal={{ ex.internal }} auto_delete={{ ex.auto_delete }} # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
- /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require:
- service: rabbitmq-service-running-service-running-{{ name }}
- sls: {{ sls_config_plugins }}
- sls: {{ sls_config_users }}
- sls: {{ sls_config_vhosts }}
{%- endfor %}
{%- endif %}
Expand Down
17 changes: 14 additions & 3 deletions rabbitmq/config/plugins/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name, node in rabbitmq.nodes.items() %}
{%- if 'plugins' in node and node.plugins is iterable and node.plugins is not string %}
Expand All @@ -12,13 +16,20 @@ rabbitmq-config-plugins-disabled-{{ name }}-{{ plugin }}:
cmd.run:
- name: /usr/sbin/rabbitmq-plugins --node {{ name }} disable {{ plugin }}
- onlyif:
- test -x /usr/sbin/rabbitmq-plugins
- test -d {{ rabbitmq.dir.data }}
- test -f {{ rabbitmq.dir.config }}/enabled_plugins
- /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled {{ plugin }}
- runas: root
file.absent:
- name: /usr/local/sbin/rabbitmqadmin
- require_in:
- file: rabbitmq-config-plugins-disabled-{{ name }}-{{ plugin }}
- file: rabbitmq-config-plugins-clean-rabbitmqadmin
{%- endfor %}
{%- endif %}
{%- endfor %}
rabbitmq-config-plugins-clean-rabbitmqadmin:
file.absent:
- name: /usr/local/sbin/rabbitmqadmin
- require_in:
- sls: {{ sls_service_clean }}
9 changes: 7 additions & 2 deletions rabbitmq/config/plugins/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ include:
rabbitmq-config-plugins-enabled-{{ name }}-{{ plugin }}:
cmd.run:
- name: /usr/sbin/rabbitmq-plugins --node {{ name }} enable {{ plugin }}
- name: /usr/sbin/rabbitmq-plugins --node {{ name }} enable {{ plugin }} || true
- runas: root
- onlyif: test -x /usr/sbin/rabbitmqctl
- unless: /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled {{ plugin }}
- onchanges_in:
- cmd: rabbitmq-service-running-daemon-reload
- watch_in:
- service: rabbitmq-service-running-service-running-{{ name }}
Expand All @@ -26,6 +28,9 @@ rabbitmq-config-plugins-{{ name }}-rabbitmqadmin-install:
cmd.run:
- name : curl -k -L http://localhost:15672/cli/rabbitmqadmin -o /usr/local/sbin/rabbitmqadmin
- unless: test -x /usr/local/bin/rabbitmqadmin
- onlyif: /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled {{ plugin }}
- require:
- sls: {{ sls_service_running }}
file.managed:
- name: /usr/local/sbin/rabbitmqadmin
- user: root
Expand Down
26 changes: 1 addition & 25 deletions rabbitmq/config/policies/clean.sls
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- for name, node in rabbitmq.nodes.items() %}
{%- if 'policies' in node and node.policies is mapping %}
{%- for policy, p in node.policies.items() %}
rabbitmq-config-policies-absent-{{ name }}-{{ policy }}:
rabbitmq_policy.absent:
{%- for v in p %}
{%- if 'name' in v %}
- {{ v|yaml }}
{%- endif %}
{%- endfor %}
- runas: rabbitmq
- onlyif:
- test -x /usr/sbin/rabbitmqctl
- test -d {{ rabbitmq.dir.data }}
{%- endfor %}
{%- endif %}
{%- endfor %}
# not implemented
6 changes: 2 additions & 4 deletions rabbitmq/config/queues/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %}
{%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %}
{%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %}
include:
- {{ sls_service_clean }}
- {{ sls_config_plugins_clean }}
- {{ sls_config_users_clean }}
- {{ sls_config_vhosts_clean }}
Expand All @@ -20,13 +18,13 @@ include:
rabbitmq-config-queues-disabled-{{ name }}-{{ queue }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} delete queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} || true # noqa 204
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} || true # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
- test -d {{ rabbitmq.dir.data }}
# /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require_in:
- sls: {{ sls_service_clean }}
- sls: {{ sls_config_plugins_clean }}
- sls: {{ sls_config_users_clean }}
- sls: {{ sls_config_vhosts_clean }}
Expand Down
9 changes: 4 additions & 5 deletions rabbitmq/config/queues/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %}
{%- set sls_config_users = tplroot ~ '.config.users.install' %}
{%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %}
include:
- {{ sls_service_running }}
- {{ sls_config_plugins }}
- {{ sls_config_users }}
- {{ sls_config_vhosts }}
Expand All @@ -20,11 +18,12 @@ include:
rabbitmq-config-queues-enabled-{{ name }}-{{ queue }}:
cmd.run:
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} declare queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} durable={{ q.durable|to_bool|lower }} auto_delete={{ q.auto_delete|to_bool|lower }} # noqa 204
- onlyif: test -x /usr/sbin/rabbitmqctl
- name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} durable={{ q.durable|to_bool|lower }} auto_delete={{ q.auto_delete|to_bool|lower }} # noqa 204
- onlyif:
- test -x /usr/local/sbin/rabbitmqadmin
# /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management
- runas: rabbitmq
- require:
- service: rabbitmq-service-running-service-running-{{ name }}
- sls: {{ sls_config_plugins }}
- sls: {{ sls_config_users }}
- sls: {{ sls_config_vhosts }}
Expand Down
22 changes: 1 addition & 21 deletions rabbitmq/config/upstreams/clean.sls
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %}
{%- for name, node in rabbitmq.nodes.items() %}
{%- if 'upstreams' in node and node.upstreams is mapping %}
{%- for upstream, p in node.upstreams.items() %}
rabbitmq-config-upstreams-absent-{{ name }}-{{ upstream }}:
rabbitmq_upstream.absent:
- name: {{ upstream }}
- runas: rabbitmq
- onlyif:
- test -x /usr/sbin/rabbitmqctl
- test -d {{ rabbitmq.dir.data }}
{%- endfor %}
{%- endif %}
{%- endfor %}
# not implemented
6 changes: 6 additions & 0 deletions rabbitmq/config/users/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
---
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as r with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- if grains.os_family == 'RedHat' and 'locale_all' in r.environ %}
Expand All @@ -24,6 +28,8 @@ rabbitmq-config-users-deleted-{{ name }}-{{ user }}:
- test -x /usr/sbin/rabbitmqctl
- test -d {{ r.dir.data }}
- runas: rabbitmq
- require_in:
- sls: {{ sls_service_clean }}
{%- endfor %}
{%- endif %}
Expand Down
1 change: 0 additions & 1 deletion rabbitmq/config/users/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ rabbitmq-config-users-added-{{ name }}-{{ user }}:
- runas: rabbitmq
- require:
- service: rabbitmq-service-running-service-running-{{ name }}
- require_in:
- sls: {{ sls_vhosts_install }}
{%- endfor %}
Expand Down
Loading

0 comments on commit f090d31

Please sign in to comment.