The shell module seems to escape special characters like \ and ". Is there a way so that the shell module doesn’t escape these characters? Are there any tips on how handle situations where you want double quotes?
I use shell a fair amount and have occasionally run into some similar issues. I sometimes wrap the entire shell command in single or double quotes, if it contains a special character. An example:
- name: determine firefox version
shell: “firefox -v | cut -d ’ ’ -f3”
register: ffversion
I also used double quotes with sed commands in the past, but lineinfile works just as well. However, I sometimes have to play with the quote placement for a while to make lineinfile work.
Joanna
Thanks Joanna.
I think I’ve solved my particular issue by making heavy use of templates where I can put the double quotes and backslashes where I need them, then use the dest file as input to a command (e.g., mysql < my template.sql)
Jim