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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/586e02e0-61ad-458f-8602-66977c14d411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to