title: Ansible: how to solve "sudo: a password is required" error?
body: <p>I have 9 servers and i am trying to install a package using ansible, i am able to ssh into 5 of the servers using a password and other 4 does not ask any password while ssh'ng into them. </p>
  
  <p>However i have copied id_rsa.pub key to all the 9 servers.</p>
  
  <p>Now the ansible script is working fine for 5 server but w remaining 4 i am getting the following error message.</p>
  
  <blockquote>
    <p>fatal: [xxx0?]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Connection to xxx0? closed.\r\n", "module_stdout": "sudo: a password is required\r\n", "msg": "MODULE FAILURE", "rc": 1}</p>
  </blockquote>
  
  <p>My Ansible.cfg</p>
  
  <pre><code>[defaults]
  filter_plugins =./filter_plugins
  roles_path = ./roles
  sudo_user = root
  host_key_checking = False
  retry_files_enabled = False
  password = ~/password.txt
  timeout = 25
  
  [ssh_connection]
  ssh_args = -F ~/.ssh/config -o ControlMaster=no -o ControlPersist=30m
  control_path = ~/.ssh/ansible-%%r@%%h:%%p
  </code></pre>
  
  <p>~/.ssh/config</p>
  
  <pre><code>Host xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? .xyz.com
    User yyy
    Port 22
  </code></pre>
  
  <p>ansible version = ansible 2.3.1.0</p>
  
  <p>How can i solve this error ?</p>