title: I can't execute my ansible playbook due to a "Failed to connect to the host via ssh"
body: <p>I can connect via ssh my masternode, but when I launch my ansible playbook, it says it &quot;Failed to connect to the host via ssh&quot;. I do not understand why. Could someone please help me with that.</p>
  <pre><code>[ansadmin@ip-172-31-52-198 ssh]$ cd /home/ansadmin/.ssh/
  [ansadmin@ip-172-31-52-198 .ssh]$ ssh -i  /home/ansadmin/.ssh/id_rsa2 opc@132.145.209.167
  Oracle Linux Server 7.8
  Last login: Tue Jun 30 16:42:47 2020 from 132.145.169.136
  [opc@oke-c3doyjxha4g-nrtgmbsgq3d-srmrh4en3ga-2 ~]$ exit
  logout
  Connection to 132.145.209.167 closed.
  [ansadmin@ip-172-31-52-198 .ssh]$ cd /opt/kubernetes/
  [ansadmin@ip-172-31-52-198 kubernetes]$ ansible-playbook -i hosts kubernetes-valaxy-deployment.yml -vvv
  ansible-playbook 2.9.9
    config file = /etc/ansible/ansible.cfg
    configured module search path = [u'/home/ansadmin/.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-playbook
    python version = 2.7.18 (default, May  7 2020, 09:20:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
  Using /etc/ansible/ansible.cfg as config file
  host_list declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
  script declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
  auto declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
  [DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable on deprecation. This feature 
  will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
  [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
  Parsed /opt/kubernetes/hosts inventory source with ini plugin
  
  PLAYBOOK: kubernetes-valaxy-deployment.yml *****************************************************************************************************************************************************************
  1 plays in kubernetes-valaxy-deployment.yml
  
  PLAY [Create pods using deployment] ************************************************************************************************************************************************************************
  
  TASK [Gathering Facts] *************************************************************************************************************************************************************************************
  task path: /opt/kubernetes/kubernetes-valaxy-deployment.yml:3
  &lt;132.145.209.167&gt; ESTABLISH SSH CONNECTION FOR USER: root
  &lt;132.145.209.167&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 'User=&quot;root&quot;' -o ConnectTimeout=10 -o ControlPath=/home/ansadmin/.ansible/cp/b09c8a513c 132.145.209.167 '/bin/sh -c '&quot;'&quot;'echo ~root &amp;&amp; sleep 0'&quot;'&quot;''
  &lt;132.145.209.167&gt; (255, '', 'Oracle Linux Server 7.8\nPermission denied (publickey).\r\n')
  fatal: [132.145.209.167]: UNREACHABLE! =&gt; {
      &quot;changed&quot;: false, 
      &quot;msg&quot;: &quot;Failed to connect to the host via ssh: Oracle Linux Server 7.8\nPermission denied (publickey).&quot;, 
      &quot;unreachable&quot;: true
  }
  
  PLAY RECAP *************************************************************************************************************************************************************************************************
  132.145.209.167            : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   
  
  [ansadmin@ip-172-31-52-198 kubernetes]$ cat /etc/ansible/ansible.cfg
  [defaults]
  privatekeyfile = /home/ansadmin/.ssh/id_rsa2
  </code></pre>