<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/calvinII/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/calvinII">@calvinII</a> on 2016-05-31T18:35:14Z</p>

<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">known_hosts</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

&lt;!--- Paste verbatim output from “ansible --version” between quotes --&gt;
"><pre class="notranslate"><code class="notranslate">ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

&lt;!--- Paste verbatim output from “ansible --version” between quotes --&gt;

</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Debian Jessie</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">If I call known_hosts to add a given key it changes on every call</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Easy to reproduce, insert new key via known_hosts module in your .ssh/known_hosts, check for it, retry it again, and see that it changes again even if the correct key is already in your known_hosts.</p>
<p dir="auto">Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Insert Key using known_hosts module
uhochholdinger@xelo:~$ ansible -i 'localhost,' all -m known_hosts -a 'key=&quot;xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo&quot; name=&quot;xelo&quot;'
localhost | SUCCESS =&gt; {
    &quot;changed&quot;: true, 
    &quot;gid&quot;: 10000, 
    &quot;group&quot;: &quot;np&quot;, 
    &quot;key&quot;: &quot;xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo&quot;, 
    &quot;mode&quot;: &quot;0600&quot;, 
    &quot;name&quot;: &quot;xelo&quot;, 
    &quot;owner&quot;: &quot;uhochholdinger&quot;, 
    &quot;path&quot;: &quot;/home/uhochholdinger/.ssh/known_hosts&quot;, 
    &quot;size&quot;: 300811, 
    &quot;state&quot;: &quot;file&quot;, 
    &quot;uid&quot;: 1016
}

# Check if key is available, compare with added key!
uhochholdinger@xelo:~$ ssh-keygen -F xelo
# Host xelo found: line 978 type ECDSA
xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4=

# Try to add key again
uhochholdinger@xelo:~$ ansible -i 'localhost,' all -m known_hosts -a 'key=&quot;xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo&quot; name=&quot;xelo&quot;'
localhost | SUCCESS =&gt; {
    &quot;changed&quot;: true, 
    &quot;gid&quot;: 10000, 
    &quot;group&quot;: &quot;np&quot;, 
    &quot;key&quot;: &quot;xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo&quot;, 
    &quot;mode&quot;: &quot;0600&quot;, 
    &quot;name&quot;: &quot;xelo&quot;, 
    &quot;owner&quot;: &quot;uhochholdinger&quot;, 
    &quot;path&quot;: &quot;/home/uhochholdinger/.ssh/known_hosts&quot;, 
    &quot;size&quot;: 300811, 
    &quot;state&quot;: &quot;file&quot;, 
    &quot;uid&quot;: 1016
}
"><pre class="notranslate"><code class="notranslate"># Insert Key using known_hosts module
uhochholdinger@xelo:~$ ansible -i 'localhost,' all -m known_hosts -a 'key="xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo" name="xelo"'
localhost | SUCCESS =&gt; {
    "changed": true, 
    "gid": 10000, 
    "group": "np", 
    "key": "xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo", 
    "mode": "0600", 
    "name": "xelo", 
    "owner": "uhochholdinger", 
    "path": "/home/uhochholdinger/.ssh/known_hosts", 
    "size": 300811, 
    "state": "file", 
    "uid": 1016
}

# Check if key is available, compare with added key!
uhochholdinger@xelo:~$ ssh-keygen -F xelo
# Host xelo found: line 978 type ECDSA
xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4=

# Try to add key again
uhochholdinger@xelo:~$ ansible -i 'localhost,' all -m known_hosts -a 'key="xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo" name="xelo"'
localhost | SUCCESS =&gt; {
    "changed": true, 
    "gid": 10000, 
    "group": "np", 
    "key": "xelo ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJzrHvJZ7bVys4f73Qr1B3qgLkX7sUP6JUpUgAJCCacTeelzQu2JbbOr6aho7K4k1iTZICfaEXEwFMAMtuchpw4= root@xelo", 
    "mode": "0600", 
    "name": "xelo", 
    "owner": "uhochholdinger", 
    "path": "/home/uhochholdinger/.ssh/known_hosts", 
    "size": 300811, 
    "state": "file", 
    "uid": 1016
}

</code></pre></div>
<p dir="auto">Cheers<br>
Ulli</p>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="157740068" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-extras/issues/2350" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-extras/issues/2350/hovercard" href="https://github.com/ansible/ansible-modules-extras/issues/2350">ansible/ansible-modules-extras#2350</a></p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report / Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ini_file</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.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/something/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4]"><pre class="notranslate"><code class="notranslate">ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/something/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">DEFAULT_REMOTE_PORT(/etc/ansible/ansible.cfg) = 22<br>
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ubuntu Server 16.04 LTS, 64-bit</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When writing INI files from two instances to the same file and host it sometimes corrupts the file, resulting in wrong INI syntax (duplicates or a half section written to file).</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Try to setup a test host and write to a INI file, execute the playbook/script few times at the same time.</p>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">I understand that it's a bad concept of potentially having the INI write at the same time, but with some deployment setup it could happen at any time you have scheduled tasks and manual tasks at the same time. It would be awesome to have a lock mechanism to the INI function.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Duplicates or weird syntax in the ini file.</p>