# Variables with quotes

**URL:** <https://forum.ansible.com/t/variables-with-quotes/27271>\
**Category:** Ansible Project\
**Created:** [April 13, 2018, 1:48pm UTC](https://forum.ansible.com/t/variables-with-quotes/27271 "2018-04-13T13:48:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaun\_Lim](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Shaun\_Lim](https://forum.ansible.com/u/Shaun_Lim)\
**Post date:** [April 13, 2018, 1:48pm UTC](https://forum.ansible.com/t/variables-with-quotes/27271/1 "2018-04-13T13:48:15Z")

</div>

Hi all,

I’m new to Ansible and am trying to use some variables with quotes. The command I’m trying to run is as follows:

`rabbitmqctl set_permissions -p /vhost username ".*" ".*" ".*"`

To do this, I’m trying to use the command module. If I include the command exactly as above, the command runs successfully but I’m trying to make this reusable so I’ve changed a few of those into variables instead. My task currently looks like this:

`

- name: Set user permissions on RabbitMQ  
become: yes  
command: rabbitmqctl set\_permissions -p /“{{ rabbitVhost }}” “{{ rabbitUser }}” “{{ rabbitAcl }}”  
`

I can’t seem to get this to work. I’ve tried sending the parameters like this:

`ansible-playbook rabbit.yml --extra-vars='{"rabbitUser":"shaun","rabbitSecret":"P@ssw0rd","rabbitVhost":"sensu","rabbitAcl":"\\\".*\\\" \\\".*\\\" \\\".*\\\""}'`

The error I get is as below and it looks like the parameters are being set correctly:

`fatal: [localhost]: FAILED! => { "changed": true, "cmd": ["rabbitmqctl", "set_permissions", "-p", "/sensu", "shaun", "\".*\" \".*\" \".*\""], "delta": "0:00:00.691783", "end": "2018-04-13 23:37:49.505521", "invocation": { "module_args": { "_raw_params": "rabbitmqctl set_permissions -p /\"sensu\" \"shaun\" \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "warn": true } }, "msg": "non-zero return code", "rc": 64, "start": "2018-04-13 23:37:48.813738", "stderr": "Error: operation set_permissions used with invalid parameter: [\"shaun\",\n \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]", "stderr_lines": ["Error: operation set_permissions used with invalid parameter: [\"shaun\",", " \"\\\".*\\\" \\\".*\\\" \\\".*\\\"\"]" ],`

Any help would be appreciated.

Thanks.

Regards,  
Shaun

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [April 14, 2018, 5:05am UTC](https://forum.ansible.com/t/variables-with-quotes/27271/2 "2018-04-14T05:05:09Z")

</div>

Try to use the Ansible rabbitmq\_user module as this will be much easier to accomplish your needs.

[http://docs.ansible.com/ansible/latest/modules/rabbitmq\_user\_module.html](http://docs.ansible.com/ansible/latest/modules/rabbitmq_user_module.html)

---

<div class="post-metadata">

**Author:** ![Shaun\_Lim](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Shaun\_Lim](https://forum.ansible.com/u/Shaun_Lim)\
**Post date:** [April 15, 2018, 4:10am UTC](https://forum.ansible.com/t/variables-with-quotes/27271/3 "2018-04-15T04:10:04Z")

</div>

Thanks for the tip Larry.

I wanted to create my own module as I am learning Ansible.

In any case, I managed to get it done by splitting each type of permission into its own variable. I think a combined string with too many quotes caused some parsing issues.

Regards,  
Shaun

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [April 15, 2018, 1:21pm UTC](https://forum.ansible.com/t/variables-with-quotes/27271/4 "2018-04-15T13:21:14Z")

</div>

Absolutely and completely understand.

Good luck with your learning.
