MOS compat
diff --git a/rabbitmq/server/user.sls b/rabbitmq/server/user.sls
index b11b78b..b2b7a0b 100644
--- a/rabbitmq/server/user.sls
+++ b/rabbitmq/server/user.sls
@@ -6,6 +6,10 @@
{%- if server.admin is defined %}
+{%- if salt['pkg.version_installed'](server.pkg) %}
+
+{%- if not salt['rabbitmq.user_exists'](server.admin.name) %}
+
rabbit_user_admin_present:
rabbitmq_user.present:
- name: {{ server.admin.name }}
@@ -24,13 +28,54 @@
{%- endif %}
-{%- if 'guest' not in rabbitmq_users.keys() %}
+{%- else %}
+
+rabbit_user_admin_present:
+ rabbitmq_user.present:
+ - name: {{ server.admin.name }}
+ - password: {{ server.admin.password }}
+ - force: True
+ - tags: management administrator
+ - perms:
+ {%- for vhost_name, vhost in server.get('host', {}).iteritems() %}
+ - '{{ vhost_name }}':
+ - '.*'
+ - '.*'
+ - '.*'
+ {%- endfor %}
+ - require:
+ - service: rabbitmq_service
+
+{%- endif %}
+
+{%- endif %}
+
+{%- if salt['pkg.version_installed'](server.pkg) %}
+
+{%- if 'guest' not in rabbitmq_users.keys() and salt['rabbitmq.user_exists']('guest') %}
+
{#- Delete default guest user if we are not using it #}
rabbitmq_user_guest_absent:
rabbitmq_user.absent:
- name: guest
- require:
- service: rabbitmq_service
+
+{%- endif %}
+
+{%- else %}
+
+{%- if 'guest' not in rabbitmq_users.keys() %}
+
+{#- Delete default guest user if we are not using it #}
+rabbitmq_user_guest_absent:
+ rabbitmq_user.absent:
+ - name: guest
+ - require:
+ - service: rabbitmq_service
+
+{%- endif %}
+
{%- endif %}
{%- endif %}
diff --git a/rabbitmq/server/vhost.sls b/rabbitmq/server/vhost.sls
index 6e06ede..ecb7308 100644
--- a/rabbitmq/server/vhost.sls
+++ b/rabbitmq/server/vhost.sls
@@ -11,21 +11,48 @@
- name: {{ host_name }}
- require:
- service: rabbitmq_service
- - require_in:
- - rabbitmq_user: rabbitmq_user_{{ host.user }}
{%- endif %}
+{%- if salt['pkg.version_installed'](server.pkg) %}
+
+{%- if not salt['rabbitmq.user_exists'](host.user) %}
+
rabbitmq_user_{{ host.user }}:
rabbitmq_user.present:
- name: {{ host.user }}
- password: {{ host.password }}
- force: true
+ {%- if host_name != '/' %}
+ - require:
+ - rabbitmq_vhost_{{ host_name }}
+ {%- endif %}
- perms:
- '{{ host_name }}':
- '.*'
- '.*'
- '.*'
+{%- endif %}
+
+{%- else %}
+
+rabbitmq_user_{{ host.user }}:
+ rabbitmq_user.present:
+ - name: {{ host.user }}
+ - password: {{ host.password }}
+ - force: true
+ {%- if host_name != '/' %}
+ - require:
+ - rabbitmq_vhost_{{ host_name }}
+ {%- endif %}
+ - perms:
+ - '{{ host_name }}':
+ - '.*'
+ - '.*'
+ - '.*'
+
+{%- endif %}
+
{%- for policy in host.get('policies', []) %}
rabbitmq_policy_{{ host_name }}_{{ policy.name }}: