How to pass list of arguments that contains "=" signs to raw command ?

I’m trying to find an easy way to specify args to a command.
The args contain ‘=’ signs triggering the error

A variable inserted a new parameter into the module args. Be sure to quote variables if they contain equal signs (for example: "{{var}}").

Can you help me find the magic syntax?

- hosts: somehost
  vars:
    - container_commands:
        ops_registry_1: -e SOMEVAR='122' -e bla='123' -e another='1233'
   - container_name: ops_registry_1
  tasks:
     - name: run docker command
       raw: "docker run {{ container_commands[container_name] }} registry:2.0"

`

I’ve considered:

  • putting all the args in a environment hash and join them, but I guess it’s the same issue.
  • using with_items but this gave the same issue
  • using single , double etc… quotes

thanks for your assistance
`

raw: "docker run {{ container_commands[container_name] }} registry:2.0"

raw:

Executes a low-down and dirty SSH command, not going through the module subsystem. This is useful and should only be done in two cases. The first case is installing python-simplejson on older (Python 2.4 and before) hosts that need it as a dependency to run modules, since nearly all core modules require it. Another is speaking to any devices such as routers that do not have any Python installed. In any other case, using the shell or command module is much more appropriate.

Have you tried command or shell?

Cheers,
Paul

Have you tried command or shell?

Yes I did, I guess it’s a general security safeguard . But how to express/escape it correctly.
I now work around through generating a script file through a template and executing that.
But I guess there must be a more elegant way?

Your example seems to work with command instead of raw:

$ ansible-playbook --version
ansible-playbook 1.9.1
  configured module search path = None

$ ansible-playbook /var/tmp/equal.yml

PLAY [localhost] **************************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [run docker command] ****************************************************
changed: [localhost]

TASK: [debug var=output['stdout_lines']] **************************************
ok: [localhost] => {
    "var": {
        "output['stdout_lines']": [
            "['/var/tmp/test.py', 'run', '-e', 'SOMEVAR=122', '-e',
'bla=123', '-e', 'another=1233', 'registry:2.0']"
        ]
    }
}

PLAY RECAP ********************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0

$ cat /var/tmp/equal.yml