Command module and quotes

119 views
Skip to first unread message

burn...@umn.edu

unread,
Mar 17, 2017, 10:06:28 AM3/17/17
to Ansible Project
Hello everyone - I have a simply quotation question that I can't seem to find an answer to online for some reason.

What is the proper way to wrap this command module task, such that the embedded quotes and variables still pass through properly?

- name: Gather {{ uid }} system account password
# Requires the CLI agent to be installed and configured on the target server.
# Uses the delegate_to command to ensure CLI is run on proper node. Defined in group_vars.
  tags
: CLI
  command
: '/opt/CARKaim/sdk/clipasswordsdk GetPassword -p AppDescs.AppID={{ CA_AppID }} -p Query="Safe={{ DIRECTORY_CA_Safe }};Folder=Root;Object={{ WMSADMIN_CA_Object }}" -p RequiredProps=Address,UserName -o Password'
 
register: wmsadmin_dir_account_pass
  changed_when
: false
  delegate_to
: "{{ CyberArkCLI_hostname_short }}"


I have the whole command wrapped in single quotes and I want to retain the raw double quotes inside the command. If I review the -vvv output, I see this. It looks like Ansible/YAML is parsing the command and dropping the quotes I have in the code. 
 
 "cmd": ["/opt/CARKaim/sdk/clipasswordsdk", "GetPassword", "-p", "AppDescs.AppID=<removed>", "-p", "Query=Safe=<removed>;Folder=Root;Object=<removed>", "-p", "RequiredProps=Address,UserName", "-o", "Password"] 

How shall I change this up to retain those quotes?

Kai Stian Olstad

unread,
Mar 17, 2017, 12:37:14 PM3/17/17
to ansible...@googlegroups.com
On 17. mars 2017 15:06, burn...@umn.edu wrote:
> - name: Gather {{ uid }} system account password
> # Requires the CLI agent to be installed and configured on the target
> server.
> # Uses the delegate_to command to ensure CLI is run on proper node. Defined
> in group_vars.
> tags: CLI
> command: '/opt/CARKaim/sdk/clipasswordsdk GetPassword -p
> AppDescs.AppID={{ CA_AppID }} -p Query="Safe={{ DIRECTORY_CA_Safe
> }};Folder=Root;Object={{ WMSADMIN_CA_Object }}" -p
> RequiredProps=Address,UserName -o Password'
> register: wmsadmin_dir_account_pass
> changed_when: false
> delegate_to: "{{ CyberArkCLI_hostname_short }}"
>
>
> I have the whole command wrapped in single quotes and I want to retain the
> raw double quotes inside the command. If I review the -vvv output, I see
> this. It looks like Ansible/YAML is parsing the command and dropping the
> quotes I have in the code.

>
> How shall I change this up to retain those quotes?

How you tried to escape the double quotes with backslash?

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages