I wish to check if my text Options
exists between opening and closing LocationMatch
tags. Below sed
command gives me the desired result.
$ sed -n '/^<LocationMatch "^\/+$">/,/^<\/LocationMatch/p' httpd.conf | grep -i 'Options '
Options -Indexes
However, I'm getting syntax error when executing the same command from ansible.
- name: Check if Options exists between Location Match tags
shell: "sed -n '/^<LocationMatch \"^\/+$\">/,/^<\/LocationMatch/p' {{ httpd_home }}/conf/httpd.conf | grep -i 'Options '"
register: Optionsexist
Output:
shell: "sed -n '/^<LocationMatch \"^\/+$\">/,/^<\/LocationMatch/p' {{ httpd_home }}/conf/httpd.conf | grep -i 'Options '"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
I did keep ansible's escape charecter before the double quotes in the sed command.
Can you please suggest a working syntax.