# 'messaging/rabbitmq\_policy' fails to set up policy parameters requiring integer as the input

**URL:** <https://forum.ansible.com/t/messaging-rabbitmq-policy-fails-to-set-up-policy-parameters-requiring-integer-as-the-input/17454>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 5, 2015, 8:29am UTC](https://forum.ansible.com/t/messaging-rabbitmq-policy-fails-to-set-up-policy-parameters-requiring-integer-as-the-input/17454 "2015-02-05T08:29:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huaxing\_Sun](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@Huaxing\_Sun](https://forum.ansible.com/u/Huaxing_Sun)\
**Post date:** [February 5, 2015, 8:29am UTC](https://forum.ansible.com/t/messaging-rabbitmq-policy-fails-to-set-up-policy-parameters-requiring-integer-as-the-input/17454/1 "2015-02-05T08:29:41Z")

</div>

I keep getting error with the following ansible command.

`

…

- name: create policy  
rabbitmq\_policy:  
name={{ item.name }}  
vhost={{ item.vhost | default(‘/’, false) }}  
pattern={{ item.pattern }}  
priority={{ item.priority }}  
tags={{ item.tags }}  
with\_items: rabbitmq\_policy\_configuration  
…

`  
where ‘rabbitmq\_policy\_configuration’ is

`

`rabbitmq_policy_configuration -name: GLOBAL vhost: / pattern: .* priority: 0 tags: ha-mode=all,ha-sync-mode=automatic,max-length=1000000,expires=1296000000`

`

When the module processes this configuration, the value of ‘tags’ is converted strictly to a _string_.  
But in fact, the values of ‘max-length’ and ‘expires’ must be _ints_ for rabbitmqctl(assuming people understand what rabbitmqctl does) to work properly.

This is the error message

`

failed: [10._._._] =\> (item={‘priority’: 0, ‘vhost’: ‘/’, ‘tags’: ‘ha-mode=all,ha-sync-mode=automatic,max-length=1000000,expires=1296000000’, ‘name’: ‘GLOBAL’, ‘pattern’: '._'}) =\> {“cmd”: “/usr/sbin/rabbitmqctl -q -n rabbit set\_policy -p / GLOBAL '._’ ‘{"ha-sync-mode": "automatic", "expires": "1296000000", "ha-mode": "all", "max-length": "1000000"}’ --priority 0", “failed”: true, “item”: {“name”: “GLOBAL”, “pattern”: "._”, “priority”: 0, “tags”: “ha-mode=all,ha-sync-mode=automatic,max-length=1000000,expires=1296000000”, “vhost”: “/”}, “rc”: 2}  
stderr: Error: Validation failed

\<\<“1296000000”\>\> is not a valid queue expiry

msg: Error: Validation failed

`

According to ansible docs, ‘tags’ can be a dictionary so I tried with this  
`  
rabbitmq\_policy\_configuration:

- name: GLOBAL  
vhost: /  
pattern: .\*  
priority: 0  
tags:  
ha-mode: all  
ha-sync-mode: automatic  
max-length: 1000000  
expires: 1296000000  
`  
But it did not prevail.

`  
failed: [10._._._] =\> (item={‘priority’: 0, ‘vhost’: ‘/’, ‘tags’: {‘ha-sync-mode’: ‘automatic’, ‘expires’: 1296000000, ‘ha-mode’: ‘all’, ‘max-length’: 1000000}, ‘name’: ‘GLOBAL’, ‘pattern’: '._‘}) =\> {“failed”: true, “item”: {“name”: “GLOBAL”, “pattern”: "._", “priority”: 0, “tags”: {“expires”: 1296000000, “ha-mode”: “all”, “ha-sync-mode”: “automatic”, “max-length”: 1000000}, “vhost”: “/”}}  
msg: this module requires key=value arguments ([‘name=GLOBAL’, ‘vhost=/’, 'pattern=._’, ‘priority=0’, ‘tags={ha-sync-mode:’, ‘automatic,’, ‘expires:’, ‘1296000000,’, ‘ha-mode:’, ‘all,’, ‘max-length:’, ‘1000000}’])

FATAL: all hosts have already failed – aborting

`

Could anyone please help pointing out what I have done wrong? I read the source of rabbitmq\_policy on github and did not spot any type conversions of individual parameter values belong to the argument of ‘tags’. I am starting to doubt there is a bug.

FYI these are the environment information  
Ansible version: 1.7.2-1ppa~precise  
PC environment: Ubuntu 12.04

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [February 5, 2015, 9:13am UTC](https://forum.ansible.com/t/messaging-rabbitmq-policy-fails-to-set-up-policy-parameters-requiring-integer-as-the-input/17454/2 "2015-02-05T09:13:28Z")

</div>

Hi Huaxing,

This appears to be a simple formatting error. In your first example, you are mixing up the “complex argument” form (where everything is formatted as a dictionary in the YAML) but are specifying the tags as a comma separated list. You should be using the dictionary format for YAML for this instead:

tags:  
ha-mode: all  
ha-sync-mode: automatic  
max-length: 1000000  
expires: 1296000000

And rather than using the k=v format for your task, you should be using the complex form:

- name: create policy  
rabbitmq\_policy:  
name: “{{ [item.name](http://item.name/) }}”  
vhost: “{{ item.vhost | default(‘/’, false) }}”  
pattern: “{{ item.pattern }}”  
priority: “{{ item.priority }}”  
tags: “{{ item.tags }}”  
with\_items: rabbitmq\_policy\_configuration

Let us know if this doesn’t get you past the error.

Thanks!

---

<div class="post-metadata">

**Author:** ![Huaxing\_Sun](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@Huaxing\_Sun](https://forum.ansible.com/u/Huaxing_Sun)\
**Post date:** [February 5, 2015, 9:56am UTC](https://forum.ansible.com/t/messaging-rabbitmq-policy-fails-to-set-up-policy-parameters-requiring-integer-as-the-input/17454/3 "2015-02-05T09:56:06Z")

</div>

James, thank you for the quick reply. Your advice fixed my problem. Complex form it is!!!
