<p dir="auto">apt_key module should support the following scenario:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="apt-key adv --keyserver keys.gnupg.net --recv-keys ABCDEF"><pre class="notranslate"><code class="notranslate">apt-key adv --keyserver keys.gnupg.net --recv-keys ABCDEF
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<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 = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]"><pre class="notranslate"><code class="notranslate">ansible 2.4.0.0
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">None</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Running Ansible in an Alpine 3.4.6 based container</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto"><code class="notranslate"> --ssh-common-args</code> appears to be ignored when running Ansible either ad-hoc or with a playbook</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Note the <code class="notranslate">SSH: EXEC</code> in the verbose output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible -m ping -i &quot;&lt;IP&gt;,&quot; all --ssh-common-args='-o StrictHostKeyChecking=no -o ControlPersist=59s' -vvv
ansible 2.4.0.0
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]
No config file found; using defaults
Parsed &lt;IP&gt;, inventory source with host_list plugin
META: ran handlers
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'echo ~ &amp;&amp; sleep 0'&quot;'&quot;''
The authenticity of host '&lt;IP&gt; (&lt;IP&gt;)' can't be established.
ECDSA key fingerprint is ..."><pre class="notranslate"><code class="notranslate">ansible -m ping -i "&lt;IP&gt;," all --ssh-common-args='-o StrictHostKeyChecking=no -o ControlPersist=59s' -vvv
ansible 2.4.0.0
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]
No config file found; using defaults
Parsed &lt;IP&gt;, inventory source with host_list plugin
META: ran handlers
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '"'"'echo ~ &amp;&amp; sleep 0'"'"''
The authenticity of host '&lt;IP&gt; (&lt;IP&gt;)' can't be established.
ECDSA key fingerprint is ...
</code></pre></div>
<p dir="auto">On 2.3.1 (Running on Ubuntu 16.04 directly on my workstation) works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible -m ping -i &quot;172.31.14.254,&quot; all --ssh-common-args='-o StrictHostKeyChecking=no -o ControlPersist=59s' -vvv
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'echo ~ &amp;&amp; sleep 0'&quot;'&quot;''
&lt;IP&gt; (0, '/home/tome\n', &quot;Warning: Permanently added '&lt;IP&gt;' (ECDSA) to the list of known hosts.\r\n&quot;)
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'( umask 77 &amp;&amp; mkdir -p &quot;` echo /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856 `&quot; &amp;&amp; echo ansible-tmp-1507138219.74-130573501046856=&quot;` echo /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856 `&quot; ) &amp;&amp; sleep 0'&quot;'&quot;''
&lt;IP&gt; (0, 'ansible-tmp-1507138219.74-130573501046856=/home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856\n', '')
&lt;IP&gt; PUT /tmp/tmpTt54oB TO /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py
&lt;IP&gt; SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 '[&lt;IP&gt;]'
&lt;IP&gt; (0, 'sftp&gt; put /tmp/tmpTt54oB /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py\n', '')
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'chmod u+x /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py &amp;&amp; sleep 0'&quot;'&quot;''
&lt;IP&gt; (0, '', '')
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 -tt &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'/usr/bin/python /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py; rm -rf &quot;/home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'&quot;'&quot;''
&lt;IP&gt; (0, '\r\n{&quot;invocation&quot;: {&quot;module_args&quot;: {&quot;data&quot;: null}}, &quot;changed&quot;: false, &quot;ping&quot;: &quot;pong&quot;}\r\n', 'Shared connection to &lt;IP&gt; closed.\r\n')
&lt;IP&gt; | SUCCESS =&gt; {
    &quot;changed&quot;: false, 
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;data&quot;: null
        }
    }, 
    &quot;ping&quot;: &quot;pong&quot;
}
META: ran handlers
META: ran handlers"><pre class="notranslate"><code class="notranslate">ansible -m ping -i "172.31.14.254," all --ssh-common-args='-o StrictHostKeyChecking=no -o ControlPersist=59s' -vvv
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '"'"'echo ~ &amp;&amp; sleep 0'"'"''
&lt;IP&gt; (0, '/home/tome\n', "Warning: Permanently added '&lt;IP&gt;' (ECDSA) to the list of known hosts.\r\n")
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856 `" &amp;&amp; echo ansible-tmp-1507138219.74-130573501046856="` echo /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856 `" ) &amp;&amp; sleep 0'"'"''
&lt;IP&gt; (0, 'ansible-tmp-1507138219.74-130573501046856=/home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856\n', '')
&lt;IP&gt; PUT /tmp/tmpTt54oB TO /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py
&lt;IP&gt; SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 '[&lt;IP&gt;]'
&lt;IP&gt; (0, 'sftp&gt; put /tmp/tmpTt54oB /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py\n', '')
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '"'"'chmod u+x /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py &amp;&amp; sleep 0'"'"''
&lt;IP&gt; (0, '', '')
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPersist=59s -o ControlPath=/home/tom/.ansible/cp/f2b236ed58 -tt &lt;IP&gt; '/bin/sh -c '"'"'/usr/bin/python /home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/ping.py; rm -rf "/home/tome/.ansible/tmp/ansible-tmp-1507138219.74-130573501046856/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'"'"''
&lt;IP&gt; (0, '\r\n{"invocation": {"module_args": {"data": null}}, "changed": false, "ping": "pong"}\r\n', 'Shared connection to &lt;IP&gt; closed.\r\n')
&lt;IP&gt; | SUCCESS =&gt; {
    "changed": false, 
    "invocation": {
        "module_args": {
            "data": null
        }
    }, 
    "ping": "pong"
}
META: ran handlers
META: ran handlers
</code></pre></div>
<p dir="auto">Using <code class="notranslate">host_key_checking = False</code> in <code class="notranslate">ansible.cfg</code> with 2.4.0 works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/ # cat /etc/ansibleansible.cfg 
[defaults]
host_key_checking = False
/ # ansible -m ping -i &quot;&lt;IP&gt;,&quot; all --ssh-common-args='-o StrictHostKeyChecking=no' -vvv
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed &lt;IP&gt;, inventory source with host_list plugin
META: ran handlers
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '&quot;'&quot;'echo ~ &amp;&amp; sleep 0'&quot;'&quot;''
&lt;IP&gt; (255, b'', b'Permission denied (publickey).\r\n')
&lt;IP&gt; | UNREACHABLE! =&gt; {
    &quot;changed&quot;: false,
    &quot;msg&quot;: &quot;Failed to connect to the host via ssh: Permission denied (publickey).\r\n&quot;,
    &quot;unreachable&quot;: true
}"><pre class="notranslate"><code class="notranslate">/ # cat /etc/ansibleansible.cfg 
[defaults]
host_key_checking = False
/ # ansible -m ping -i "&lt;IP&gt;," all --ssh-common-args='-o StrictHostKeyChecking=no' -vvv
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.2 (default, Sep 13 2017, 14:36:29) [GCC 5.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed &lt;IP&gt;, inventory source with host_list plugin
META: ran handlers
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/system/ping.py
&lt;IP&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;IP&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/f2b236ed58 &lt;IP&gt; '/bin/sh -c '"'"'echo ~ &amp;&amp; sleep 0'"'"''
&lt;IP&gt; (255, b'', b'Permission denied (publickey).\r\n')
&lt;IP&gt; | UNREACHABLE! =&gt; {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n",
    "unreachable": true
}
</code></pre></div>
<p dir="auto">Taking a quick glance I can't see why this is no longer working but I might be missing something obvious.</p>