title: ansible lineinfile regex multiline
body: <p>I'm trying to edit apache.conf using Ansible. Here's part of my conf: </p>
  
  <pre><code># Sets the default security model of the Apache2 HTTPD server. It does
  # not allow access to the root filesystem outside of /usr/share and /var/www.
  # The former is used by web applications packaged in Debian,
  # the latter may be used for local directories served by the web server. If
  # your system is serving content from a sub-directory in /srv you must allow
  # access here, or in any related virtual host.
  &lt;Directory /&gt;
          Options FollowSymLinks
          AllowOverride None
          Require all denied
  &lt;/Directory&gt;
  
  &lt;Directory /usr/share&gt;
          AllowOverride None
          Require all granted
  &lt;/Directory&gt;
  
  &lt;Directory /var/www/&gt;
          Options Indexes FollowSymLinks
          AllowOverride None
          Require all granted
  &lt;/Directory&gt;
  
  #&lt;Directory /srv/&gt;
  #       Options Indexes FollowSymLinks
          AllowOverride All
  #       Require all granted
  #&lt;/Directory&gt;
  </code></pre>
  
  <p>I want to change this block</p>
  
  <pre><code>&lt;Directory /var/www/&gt;
              Options Indexes FollowSymLinks
              AllowOverride None
              Require all granted
      &lt;/Directory&gt;
  </code></pre>
  
  <p>into</p>
  
  <pre><code>&lt;Directory /var/www/&gt;
              Options Indexes FollowSymLinks
              AllowOverride All
              Require all granted
      &lt;/Directory&gt;
  </code></pre>
  
  <p>set AllowOverride from None to All. I'm using this ansible task</p>
  
  <pre><code>- name: change htaccess support
    lineinfile:
      dest: /etc/apache2/apache2.conf
      regexp: '\s&lt;Directory /var/www/&gt;\n\sOptions Indexes FollowSymLinks\n\sAllowOverride'
      line: "AllowOverride All"
    tags:
      - test
  </code></pre>
  
  <p>However, AllowOverride All always added to the end of file. What's the correct regex pattern to do this jobs. I don't use ansible template cuz I only change one line.</p>