sed语法不适用于Ansible shell模块

sed语法不适用于Ansible shell模块,sed,ansible,syntax-error,full-text-search,ansible-2.x,Sed,Ansible,Syntax Error,Full Text Search,Ansible 2.x,我想检查我的文本选项是否存在于打开和关闭位置匹配标记之间。下面的sed命令给出了所需的结果 $ sed -n '/^<LocationMatch "^\/+$">/,/^<\/LocationMatch/p' httpd.conf | grep -i 'Options ' Options -Indexes $sed-n'/^/,/^和User@Zeitounators建议下面的带转义符的格式化代码有助于克服语法错误 - name: Check if Options exi

我想检查我的文本
选项
是否存在于打开和关闭
位置匹配
标记之间。下面的
sed
命令给出了所需的结果

$ sed -n '/^<LocationMatch "^\/+$">/,/^<\/LocationMatch/p' httpd.conf |  grep -i 'Options '
 Options -Indexes

$sed-n'/^/,/^和User@Zeitounators建议下面的带转义符的格式化代码有助于克服语法错误

- 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
-name:检查位置匹配标记之间是否存在选项

shell:“sed-n'/^/,/^如果在最后一个字符串中需要反斜杠,则需要在yaml双引号包围的标量中对其进行转义(即双反斜杠)
      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 }}"
- 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