I have a group_vars/all file that looks like this:

---

cbe_ios:
  navBarLogoName: 
    value: "null"
    description: "null"
    tenant_override: keep

I want to use this file to generate a command-line call to mysql that looks 
like this:

use cbe_config; insert into settings (application, setting_key, 
setting_value, description) values ("cbe-ios", "navBarLogoName",
* "\"null\""*, null) on duplicate key update setting_value=*"\"null\""*, 
description=null;

Note that I want to put double quotes around the word null in two places to 
be a valid JSON string. This will make the value in the database to be 
"null" and not NULL for the setting_value.

A close attempt is this:

- name: upsert values for cbe-ios
  shell: mysql -e "use cbe_config; insert into settings (application, 
setting_key, setting_value, description) values ('cbe-ios', '{{ item.key 
}}', \"{{ item.value.value }}\", {{ item.value.description }}) on duplicate 
key update setting_value=\"{{ item.value.value }}\", description={{ 
item.value.description }};"
  with_dict: cbe_ios
  tags: 
    - upsert


Unfortunately, the shell module tries to escape all special characters and 
produces something like this when I run with the -v option:

TASK: [upsert_values | upsert values for cbe-ios] 
***************************** 
changed: [dev-cbeserver1.flatworld.com] => (item={'key': 'navBarLogoName', 
'value': {'tenant_override': 'keep', 'description': 'null', 'value': 
'null'}}) => {"changed": true, "cmd": "mysql -e \"use cbe_config; insert 
into settings (application, setting_key, setting_value, description) values 
('cbe-ios', 'navBarLogoName',* \\\"null\\\"*, null) on duplicate key update 
setting_value=*\\\"null\\\",* description=null;\"", "delta": 
"0:00:00.061831", "end": "2015-03-04 16:51:50.054666", "item": {"key": 
"navBarLogoName", "value": {"description": "null", "tenant_override": 
"keep", "value": "null"}}, "rc": 0, "start": "2015-03-04 16:51:49.992835", 
"stderr": "", "stdout": "", "warnings": []}

How do I get the shell module to give me the double quotes I want?

Thanks



-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b4ed7313-4a90-4c97-85fd-32b7d4e1c725%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to