Skip to content

Commit

Permalink
fix(erlang): erlang.cookie is linked to rabbitmq user homedir
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 28, 2021
1 parent 3b93fd2 commit c568698
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 73 deletions.
6 changes: 3 additions & 3 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# vim: ft=yaml
---
rabbitmq:
erlang_cookie: shared-secret
nodes:
rabbit: # default node name
config:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions rabbitmq/config/clusters/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
12 changes: 5 additions & 7 deletions rabbitmq/config/clusters/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
1 change: 0 additions & 1 deletion rabbitmq/config/files/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
31 changes: 14 additions & 17 deletions rabbitmq/config/files/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -26,30 +38,15 @@ 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:
- service: rabbitmq-service-running-service-running-{{ name }}
{%- endif %}
{%- endfor %}
{%- if 'environ' in r and r.environ %}
rabbitmq-config-files-environ-managed:
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/parameters/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions rabbitmq/service/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/centos-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/centos-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/debian-10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/debian-11.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/debian-9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/fedora-32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions test/integration/default/files/_mapdata/fedora-33.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ values:
environ:
locale_all: en_US.UTF-8
values: {}
erlang_cookie: shared-secret
map_jinja:
sources:
- Y:G@osarch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
Loading

0 comments on commit c568698

Please sign in to comment.