salt.modules.rabbitmq

Module to provide RabbitMQ compatibility to Salt. Todo: A lot, need to add cluster support, logging, and minion configuration data.

salt.modules.rabbitmq.add_user(name, password=None, runas=None)

Add a rabbitMQ user via rabbitmqctl user_add <user> <password>

CLI Example:

salt '*' rabbitmq.add_user rabbit_user password
salt.modules.rabbitmq.add_vhost(vhost, runas=None)

Adds a vhost via rabbitmqctl add_vhost.

CLI Example:

salt '*' rabbitmq add_vhost '<vhost_name>'
salt.modules.rabbitmq.change_password(name, password, runas=None)

Changes a user's password.

CLI Example:

salt '*' rabbitmq.change_password rabbit_user password
salt.modules.rabbitmq.check_password(name, password, runas=None)

New in version 2016.3.0.

Checks if a user's password is valid.

CLI Example:

salt '*' rabbitmq.check_password rabbit_user password
salt.modules.rabbitmq.clear_password(name, runas=None)

Removes a user's password.

CLI Example:

salt '*' rabbitmq.clear_password rabbit_user
salt.modules.rabbitmq.cluster_status(runas=None)

return rabbitmq cluster_status

CLI Example:

salt '*' rabbitmq.cluster_status
salt.modules.rabbitmq.delete_policy(vhost, name, runas=None)

Delete a policy based on rabbitmqctl clear_policy.

Reference: http://www.rabbitmq.com/ha.html

CLI Example:

salt '*' rabbitmq.delete_policy / HA
salt.modules.rabbitmq.delete_upstream(name, runas=None)

Deletes an upstream via rabbitmqctl clear_parameter.

Parameters:
  • name (str) -- The name of the upstream to delete.

  • runas (str) -- The name of the user to run the command as.

CLI Example:

salt '*' rabbitmq.delete_upstream upstream_name

New in version 3000.

salt.modules.rabbitmq.delete_user(name, runas=None)

Deletes a user via rabbitmqctl delete_user.

CLI Example:

salt '*' rabbitmq.delete_user rabbit_user
salt.modules.rabbitmq.delete_vhost(vhost, runas=None)

Deletes a vhost rabbitmqctl delete_vhost.

CLI Example:

salt '*' rabbitmq.delete_vhost '<vhost_name>'
salt.modules.rabbitmq.disable_plugin(name, runas=None)

Disable a RabbitMQ plugin via the rabbitmq-plugins command.

CLI Example:

salt '*' rabbitmq.disable_plugin foo
salt.modules.rabbitmq.enable_plugin(name, runas=None)

Enable a RabbitMQ plugin via the rabbitmq-plugins command.

CLI Example:

salt '*' rabbitmq.enable_plugin foo
salt.modules.rabbitmq.force_reset(runas=None)

Forcefully Return a RabbitMQ node to its virgin state

CLI Example:

salt '*' rabbitmq.force_reset
salt.modules.rabbitmq.join_cluster(host, user='rabbit', ram_node=None, runas=None)

Join a rabbit cluster

CLI Example:

salt '*' rabbitmq.join_cluster rabbit.example.com rabbit
salt.modules.rabbitmq.list_available_plugins(runas=None)

Returns a list of the names of all available plugins (enabled and disabled).

CLI Example:

salt '*' rabbitmq.list_available_plugins
salt.modules.rabbitmq.list_enabled_plugins(runas=None)

Returns a list of the names of the enabled plugins.

CLI Example:

salt '*' rabbitmq.list_enabled_plugins
salt.modules.rabbitmq.list_permissions(vhost, runas=None)

Lists permissions for vhost via rabbitmqctl list_permissions

CLI Example:

salt '*' rabbitmq.list_permissions /myvhost
salt.modules.rabbitmq.list_policies(vhost='/', runas=None)

Return a dictionary of policies nested by vhost and name based on the data returned from rabbitmqctl list_policies.

Reference: http://www.rabbitmq.com/ha.html

CLI Example:

salt '*' rabbitmq.list_policies
salt.modules.rabbitmq.list_queues(runas=None, *args)

Returns queue details of the / virtual host

CLI Example:

salt '*' rabbitmq.list_queues messages consumers
salt.modules.rabbitmq.list_queues_vhost(vhost, runas=None, *args)

Returns queue details of specified virtual host. This command will consider first parameter as the vhost name and rest will be treated as queueinfoitem. For getting details on vhost /, use list_queues instead).

CLI Example:

salt '*' rabbitmq.list_queues messages consumers
salt.modules.rabbitmq.list_upstreams(runas=None)

Returns a dict of upstreams based on rabbitmqctl list_parameters.

Parameters:

runas (str) -- The name of the user to run this command as.

CLI Example:

salt '*' rabbitmq.list_upstreams

New in version 3000.

salt.modules.rabbitmq.list_user_permissions(name, runas=None)

List permissions for a user via rabbitmqctl list_user_permissions

CLI Example:

salt '*' rabbitmq.list_user_permissions user
salt.modules.rabbitmq.list_users(runas=None)

Return a list of users based off of rabbitmqctl user_list.

CLI Example:

salt '*' rabbitmq.list_users
salt.modules.rabbitmq.list_vhosts(runas=None)

Return a list of vhost based on rabbitmqctl list_vhosts.

CLI Example:

salt '*' rabbitmq.list_vhosts
salt.modules.rabbitmq.plugin_is_enabled(name, runas=None)

Return whether the plugin is enabled.

CLI Example:

salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name
salt.modules.rabbitmq.policy_exists(vhost, name, runas=None)

Return whether the policy exists based on rabbitmqctl list_policies.

Reference: http://www.rabbitmq.com/ha.html

CLI Example:

salt '*' rabbitmq.policy_exists / HA
salt.modules.rabbitmq.reset(runas=None)

Return a RabbitMQ node to its virgin state

CLI Example:

salt '*' rabbitmq.reset
salt.modules.rabbitmq.set_permissions(vhost, user, conf='.*', write='.*', read='.*', runas=None)

Sets permissions for vhost via rabbitmqctl set_permissions

CLI Example:

salt '*' rabbitmq.set_permissions myvhost myuser
salt.modules.rabbitmq.set_policy(vhost, name, pattern, definition, priority=None, runas=None, apply_to=None)

Set a policy based on rabbitmqctl set_policy.

Reference: http://www.rabbitmq.com/ha.html

CLI Example:

salt '*' rabbitmq.set_policy / HA '.*' '{"ha-mode":"all"}'
salt.modules.rabbitmq.set_upstream(name, uri, prefetch_count=None, reconnect_delay=None, ack_mode=None, trust_user_id=None, exchange=None, max_hops=None, expires=None, message_ttl=None, ha_policy=None, queue=None, runas=None)

Configures an upstream via rabbitmqctl set_parameter. This can be an exchange-upstream, a queue-upstream or both.

Parameters:

name (str) -- The name of the upstream to configure.

The following parameters apply to federated exchanges and federated queues:

Parameters:
  • uri (str) -- The AMQP URI(s) for the upstream.

  • prefetch_count (int) -- The maximum number of unacknowledged messages copied over a link at any one time. Default: 1000

  • reconnect_delay (int) -- The duration (in seconds) to wait before reconnecting to the broker after being disconnected. Default: 1

  • ack_mode (str) -- Determines how the link should acknowledge messages. If set to on-confirm (the default), messages are acknowledged to the upstream broker after they have been confirmed downstream. This handles network errors and broker failures without losing messages, and is the slowest option. If set to on-publish, messages are acknowledged to the upstream broker after they have been published downstream. This handles network errors without losing messages, but may lose messages in the event of broker failures. If set to no-ack, message acknowledgements are not used. This is the fastest option, but may lose messages in the event of network or broker failures.

  • trust_user_id (bool) -- Determines how federation should interact with the validated user-id feature. If set to true, federation will pass through any validated user-id from the upstream, even though it cannot validate it itself. If set to false or not set, it will clear any validated user-id it encounters. You should only set this to true if you trust the upstream server (and by extension, all its upstreams) not to forge user-ids.

The following parameters apply to federated exchanges only:

Parameters:
  • exchange (str) -- The name of the upstream exchange. Default is to use the same name as the federated exchange.

  • max_hops (int) -- The maximum number of federation links that a message published to a federated exchange can traverse before it is discarded. Default is 1. Note that even if max-hops is set to a value greater than 1, messages will never visit the same node twice due to travelling in a loop. However, messages may still be duplicated if it is possible for them to travel from the source to the destination via multiple routes.

  • expires (int) -- The expiry time (in milliseconds) after which an upstream queue for a federated exchange may be deleted, if a connection to the upstream broker is lost. The default is 'none', meaning the queue should never expire. This setting controls how long the upstream queue will last before it is eligible for deletion if the connection is lost. This value is used to set the "x-expires" argument for the upstream queue.

  • message_ttl (int) -- The expiry time for messages in the upstream queue for a federated exchange (see expires), in milliseconds. Default is None, meaning messages should never expire. This does not apply to federated queues. This value is used to set the "x-message-ttl" argument for the upstream queue.

  • ha_policy (str) -- Determines the "x-ha-policy" argument for the upstream queue for a federated exchange (see expires). This is only of interest when connecting to old brokers which determine queue HA mode using this argument. Default is None, meaning the queue is not HA.

The following parameter applies to federated queues only:

Parameters:
  • queue (str) -- The name of the upstream queue. Default is to use the same name as the federated queue.

  • runas (str) -- The name of the user to run the command as.

CLI Example:

salt '*' rabbitmq.set_upstream upstream_name ack_mode=on-confirm max_hops=1             trust_user_id=True uri=amqp://hostname

New in version 3000.

salt.modules.rabbitmq.set_user_tags(name, tags, runas=None)

Add user tags via rabbitmqctl set_user_tags

CLI Example:

salt '*' rabbitmq.set_user_tags myadmin administrator
salt.modules.rabbitmq.start_app(runas=None)

Start the RabbitMQ application.

CLI Example:

salt '*' rabbitmq.start_app
salt.modules.rabbitmq.status(runas=None)

return rabbitmq status

CLI Example:

salt '*' rabbitmq.status
salt.modules.rabbitmq.stop_app(runas=None)

Stops the RabbitMQ application, leaving the Erlang node running.

CLI Example:

salt '*' rabbitmq.stop_app
salt.modules.rabbitmq.upstream_exists(name, runas=None)

Return whether the upstreamexists based on rabbitmqctl list_parameters.

Parameters:
  • name (str) -- The name of the upstream to check for.

  • runas (str) -- The name of the user to run the command as.

CLI Example:

salt '*' rabbitmq.upstream_exists rabbit_upstream

New in version 3000.

salt.modules.rabbitmq.user_exists(name, runas=None)

Return whether the user exists based on rabbitmqctl list_users.

CLI Example:

salt '*' rabbitmq.user_exists rabbit_user
salt.modules.rabbitmq.vhost_exists(name, runas=None)

Return whether the vhost exists based on rabbitmqctl list_vhosts.

CLI Example:

salt '*' rabbitmq.vhost_exists rabbit_host