<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">setup</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.0.0
  config file = None
  configured module search path = [u'/Users/anandb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Sep 25 2017, 09:53:22) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]"><pre class="notranslate"><code class="notranslate">ansible 2.4.0.0
  config file = None
  configured module search path = [u'/Users/anandb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Sep 25 2017, 09:53:22) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">ANSIBLE_SSH_CONTROL_PATH(env: ANSIBLE_SSH_CONTROL_PATH) = /tmp/%%r@%%h<br>
ANSIBLE_SSH_PIPELINING(env: ANSIBLE_SSH_PIPELINING) = True<br>
DEFAULT_GATHERING(env: ANSIBLE_GATHERING) = smart<br>
DEFAULT_HASH_BEHAVIOUR(env: ANSIBLE_HASH_BEHAVIOUR) = merge<br>
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = [u'/Users/anandb/repo/ansible/hosts']<br>
DEFAULT_REMOTE_TMP(env: ANSIBLE_REMOTE_TEMP) = /tmp<br>
DEFAULT_TIMEOUT(env: ANSIBLE_TIMEOUT) = 75<br>
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False<br>
RETRY_FILES_ENABLED(env: ANSIBLE_RETRY_FILES_ENABLED) = False</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Running ansible from MacOSX 10.12.6, and managing CentOS 6.9</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">The ansible_service_mgr fact should contain "upstart" but contains "service" instead.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible centos6.host -bK -m setup -a filter=ansible_service_mgr"><pre class="notranslate"><code class="notranslate">ansible centos6.host -bK -m setup -a filter=ansible_service_mgr
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">I expected "ansible_service_mgr" to contain "upstart".</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="centos6.host | SUCCESS =&gt; {
    &quot;ansible_facts&quot;: {
        &quot;ansible_service_mgr&quot;: &quot;service&quot;
    }, 
    &quot;changed&quot;: false, 
    &quot;failed&quot;: false
}"><pre class="notranslate"><code class="notranslate">centos6.host | SUCCESS =&gt; {
    "ansible_facts": {
        "ansible_service_mgr": "service"
    }, 
    "changed": false, 
    "failed": false
}
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Feature Pull Request</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">All versions.</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Ubuntu 14.04, and all other.</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">The module "lineinfile" should have an option to remove duplicate lines matched by regexp.<br>
Currently it changes only the last line.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Let's say that we have the following lines in sshd_config (don't ask me how I got this):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PasswordAuthentication yes
# some stuff
PasswordAuthentication yes"><pre class="notranslate"><code class="notranslate">PasswordAuthentication yes
# some stuff
PasswordAuthentication yes
</code></pre></div>
<p dir="auto">We run ansible as:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ansible -c local -m lineinfile -a 'dest=./sshd_config  regexp=&quot;^[#\s]*PasswordAuthentication.*&quot; line=&quot;PasswordAuthentication no&quot;' localhost"><pre class="notranslate"><code class="notranslate">$ansible -c local -m lineinfile -a 'dest=./sshd_config  regexp="^[#\s]*PasswordAuthentication.*" line="PasswordAuthentication no"' localhost
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">With an option like "remove_dups=yes" we would have:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# some stuff
PasswordAuthentication no"><pre class="notranslate"><code class="notranslate"># some stuff
PasswordAuthentication no
</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PasswordAuthentication yes
# some stuff
PasswordAuthentication no"><pre class="notranslate"><code class="notranslate">PasswordAuthentication yes
# some stuff
PasswordAuthentication no
</code></pre></div>