diff --git a/pillar.example b/pillar.example index 69e1beff..4e05c033 100644 --- a/pillar.example +++ b/pillar.example @@ -2,6 +2,7 @@ # vim: ft=yaml --- rabbitmq: + erlang_cookie: shared-secret nodes: rabbit: # default node name config: @@ -105,9 +106,8 @@ rabbitmq: rabbit2: nodeport: 5673 distport: 25673 - erlang_cookie: shared-secret - clustered: false # true - join_node: rabbit@localhost # create multinode cluster on localhost + clustered: false # true + join_node: rabbit # create multinode cluster on localhost config: auth_backends.1: internal # default listeners.tcp.1: 0.0.0.0:5673 diff --git a/rabbitmq/config/clusters/clean.sls b/rabbitmq/config/clusters/clean.sls index e69f03ff..4130e42b 100644 --- a/rabbitmq/config/clusters/clean.sls +++ b/rabbitmq/config/clusters/clean.sls @@ -18,10 +18,6 @@ rabbitmq-config-clusters-{{ name }}-leave-{{ node.join_node }}: - onlyif: - test -x /usr/sbin/rabbitmqctl - test -d {{ rabbitmq.dir.data }} - file.absent: - - name: {{ rabbitmq.dir.data }}/{{ name }}/.erlang.cookie - - require: - - cmd: rabbitmq-config-clusters-{{ name }}-leave-{{ node.join_node }} {%- endif %} {%- endfor %} diff --git a/rabbitmq/config/clusters/install.sls b/rabbitmq/config/clusters/install.sls index 3e4f79c5..d2649802 100644 --- a/rabbitmq/config/clusters/install.sls +++ b/rabbitmq/config/clusters/install.sls @@ -14,22 +14,20 @@ include: {%- for name, node in rabbitmq.nodes.items() %} {%- if 'clustered' in node and node.clustered and 'join_node' in node %} - {%- if 'erlang_cookie' in node and node.erlang_cookie %} rabbitmq-config-clusters-{{ name }}-join-{{ node.join_node }}: cmd.run: - names: - - /usr/sbin/rabbitmqctl --node {{ name }}@localhost stop_app - - /usr/sbin/rabbitmqctl --node {{ name }}@localhost join_cluster {{ node.join_node }} - - /usr/sbin/rabbitmqctl --node {{ name }}@localhost start_app - - /usr/sbin/rabbitmqctl --node {{ name }}@localhost cluster_status + - /usr/sbin/rabbitmqctl --node {{ name }} stop_app + - /usr/sbin/rabbitmqctl --node {{ name }} join_cluster {{ node.join_node }} + - /usr/sbin/rabbitmqctl --node {{ name }} start_app + - /usr/sbin/rabbitmqctl --node {{ name }} cluster_status - runas: rabbitmq - onlyif: test -x /usr/sbin/rabbitmqctl - require: - - file: rabbitmq-config-files-managed-{{ name }}-erlang-cookie + - file: rabbitmq-config-files-managed-erlang-cookie - sls: {{ sls_config_users }} - service: rabbitmq-service-running-service-running-{{ name }} - {%- endif %} {%- endif %} {%- endfor %} diff --git a/rabbitmq/config/files/clean.sls b/rabbitmq/config/files/clean.sls index 34df958c..e734d9b8 100644 --- a/rabbitmq/config/files/clean.sls +++ b/rabbitmq/config/files/clean.sls @@ -14,7 +14,6 @@ rabbitmq-config-files-absent-{{ name }}: file.absent: - names: - {{ rabbitmq.dir.config }} - - {{ rabbitmq.dir.data }}/{{ name }}/.erlang.cookie - require_in: - sls: {{ sls_package_clean }} diff --git a/rabbitmq/config/files/install.sls b/rabbitmq/config/files/install.sls index 69d9795a..6dcb6a54 100644 --- a/rabbitmq/config/files/install.sls +++ b/rabbitmq/config/files/install.sls @@ -9,6 +9,18 @@ include: - {{ sls_service_running }} + {%- if 'erlang_cookie' in r and r.erlang_cookie %} + +rabbitmq-config-files-managed-erlang-cookie: + file.managed: + - name: {{ r.dir.data }}/.erlang.cookie + - contents: {{ r.erlang_cookie }} + - mode: 400 + - user: rabbitmq + - group: {{ r.rootgroup }} + - makedirs: True + + {%- endif %} {%- for name, node in r.nodes.items() %} {%- if 'config' in node and node.config is mapping %} @@ -26,22 +38,8 @@ rabbitmq-config-files-managed-{{ name }}: - template: jinja - context: config: {{ node.config | json }} - - require_in: - - service: rabbitmq-service-running-service-running-{{ name }} - - watch_in: - - service: rabbitmq-service-running-service-running-{{ name }} - - {%- endif %} - {%- if 'erlang_cookie' in node and node.erlang_cookie %} - -rabbitmq-config-files-managed-{{ name }}-erlang-cookie: - file.managed: - - name: {{ r.dir.data }}/{{ name }}/.erlang.cookie - - contents: {{ node.erlang_cookie }} - - mode: 400 - - user: rabbitmq - - group: {{ r.rootgroup }} - - makedirs: True + - require: + - file: rabbitmq-config-files-managed-erlang-cookie - require_in: - service: rabbitmq-service-running-service-running-{{ name }} - watch_in: @@ -49,7 +47,6 @@ rabbitmq-config-files-managed-{{ name }}-erlang-cookie: {%- endif %} {%- endfor %} - {%- if 'environ' in r and r.environ %} rabbitmq-config-files-environ-managed: diff --git a/rabbitmq/parameters/defaults.yaml b/rabbitmq/parameters/defaults.yaml index 200562d3..0ffb5658 100644 --- a/rabbitmq/parameters/defaults.yaml +++ b/rabbitmq/parameters/defaults.yaml @@ -4,12 +4,12 @@ # Set default values. --- values: + erlang_cookie: shared-secret nodes: rabbit: # default rabbitmq node name clustered: false nodeport: 5672 distport: 25672 - erlang_cookie: shared-secret config: {} service: true plugins: diff --git a/rabbitmq/service/clean.sls b/rabbitmq/service/clean.sls index f40d14fb..ceffc49f 100644 --- a/rabbitmq/service/clean.sls +++ b/rabbitmq/service/clean.sls @@ -15,6 +15,7 @@ rabbitmq-service-dead-service-{{ name }}: service.dead: - name: {{ svcname }} - enable: False + - onlyif: systemctl status svcname file.absent: - names: - '{{ rabbitmq.dir.service }}/{{ svcname }}.service' diff --git a/test/integration/default/files/_mapdata/centos-7.yaml b/test/integration/default/files/_mapdata/centos-7.yaml index 8f9e0b99..f9d35a8e 100644 --- a/test/integration/default/files/_mapdata/centos-7.yaml +++ b/test/integration/default/files/_mapdata/centos-7.yaml @@ -21,6 +21,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -47,7 +48,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -145,7 +145,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -158,7 +157,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/centos-8.yaml b/test/integration/default/files/_mapdata/centos-8.yaml index 6147422d..92527ba1 100644 --- a/test/integration/default/files/_mapdata/centos-8.yaml +++ b/test/integration/default/files/_mapdata/centos-8.yaml @@ -21,6 +21,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -47,7 +48,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -145,7 +145,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -158,7 +157,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/debian-10.yaml b/test/integration/default/files/_mapdata/debian-10.yaml index 5960c2c1..e57bcd60 100644 --- a/test/integration/default/files/_mapdata/debian-10.yaml +++ b/test/integration/default/files/_mapdata/debian-10.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/debian-11.yaml b/test/integration/default/files/_mapdata/debian-11.yaml index d2625aab..ec26d0f1 100644 --- a/test/integration/default/files/_mapdata/debian-11.yaml +++ b/test/integration/default/files/_mapdata/debian-11.yaml @@ -17,6 +17,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -43,7 +44,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -141,7 +141,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -154,7 +153,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/debian-9.yaml b/test/integration/default/files/_mapdata/debian-9.yaml index 2efdeac1..57bcda02 100644 --- a/test/integration/default/files/_mapdata/debian-9.yaml +++ b/test/integration/default/files/_mapdata/debian-9.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -182,7 +181,7 @@ values: - trust_user_id: true - ack_mode: on-confirm - max_hops: 1 - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost users: airflow: force: true diff --git a/test/integration/default/files/_mapdata/fedora-32.yaml b/test/integration/default/files/_mapdata/fedora-32.yaml index bbdd15f3..05c2b8f1 100644 --- a/test/integration/default/files/_mapdata/fedora-32.yaml +++ b/test/integration/default/files/_mapdata/fedora-32.yaml @@ -21,6 +21,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -47,7 +48,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -145,7 +145,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -158,7 +157,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/fedora-33.yaml b/test/integration/default/files/_mapdata/fedora-33.yaml index 928a95e3..ced5c429 100644 --- a/test/integration/default/files/_mapdata/fedora-33.yaml +++ b/test/integration/default/files/_mapdata/fedora-33.yaml @@ -21,6 +21,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -47,7 +48,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -145,7 +145,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -158,7 +157,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/fedora-34.yaml b/test/integration/default/files/_mapdata/fedora-34.yaml index 00671191..eb07d8cd 100644 --- a/test/integration/default/files/_mapdata/fedora-34.yaml +++ b/test/integration/default/files/_mapdata/fedora-34.yaml @@ -21,6 +21,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -47,7 +48,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -145,7 +145,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -158,7 +157,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/opensuse-15.yaml b/test/integration/default/files/_mapdata/opensuse-15.yaml index 341fb5e5..1b19d7d5 100644 --- a/test/integration/default/files/_mapdata/opensuse-15.yaml +++ b/test/integration/default/files/_mapdata/opensuse-15.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/opensuse-tumbleweed.yaml b/test/integration/default/files/_mapdata/opensuse-tumbleweed.yaml index 33281e78..5bb7bcd6 100644 --- a/test/integration/default/files/_mapdata/opensuse-tumbleweed.yaml +++ b/test/integration/default/files/_mapdata/opensuse-tumbleweed.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/ubuntu-16.yaml b/test/integration/default/files/_mapdata/ubuntu-16.yaml index 191eb1e3..e46c7558 100644 --- a/test/integration/default/files/_mapdata/ubuntu-16.yaml +++ b/test/integration/default/files/_mapdata/ubuntu-16.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/ubuntu-18.yaml b/test/integration/default/files/_mapdata/ubuntu-18.yaml index 711a5da9..579b4157 100644 --- a/test/integration/default/files/_mapdata/ubuntu-18.yaml +++ b/test/integration/default/files/_mapdata/ubuntu-18.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/default/files/_mapdata/ubuntu-20.yaml b/test/integration/default/files/_mapdata/ubuntu-20.yaml index f3428e5e..da475f29 100644 --- a/test/integration/default/files/_mapdata/ubuntu-20.yaml +++ b/test/integration/default/files/_mapdata/ubuntu-20.yaml @@ -19,6 +19,7 @@ values: environ: locale_all: en_US.UTF-8 values: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -45,7 +46,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5672 distport: 25672 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -143,7 +143,6 @@ values: auth_backends.1: internal listeners.tcp.1: 0.0.0.0:5673 distport: 25673 - erlang_cookie: shared-secret exchange: my-new-exchange: - user: saltstack_mq @@ -156,7 +155,7 @@ values: - arguments: - alternate-**exchange: amq.fanout - test-header: testing - join_node: rabbit@localhost # create multinode cluster on localhost + join_node: rabbit # create multinode cluster on localhost nodeport: 5673 plugins: [] policy: diff --git a/test/integration/nopillars/files/_mapdata/centos-7.yaml b/test/integration/nopillars/files/_mapdata/centos-7.yaml index 1e32e4b5..98525817 100644 --- a/test/integration/nopillars/files/_mapdata/centos-7.yaml +++ b/test/integration/nopillars/files/_mapdata/centos-7.yaml @@ -14,6 +14,7 @@ values: data: "/var/lib/rabbitmq" service: "/usr/lib/systemd/system" environ: {} + erlang_cookie: shared-secret map_jinja: sources: - Y:G@osarch @@ -28,7 +29,6 @@ values: clustered: false config: {} distport: 25672 - erlang_cookie: shared-secret nodeport: 5672 plugins: - rabbitmq_management