title: How to use ansible without ssh keys - getpwnam() MODULE FAILURE
body: <p>I am trying to use ansible without setting ssh keys. I want to log in with username and password. I have installed on the master <code>sshpass</code>.</p>
  
  <p>My <strong>directory</strong> layout looks like this:</p>
  
  <pre><code>ansible.cfg
  inventory/
      hosts
      group_vars/
          all.yaml
  roles
     whoami/
         tasks/
              main.yaml
  site.yaml
  </code></pre>
  
  <p><strong>ansible.cfg:</strong></p>
  
  <pre><code>[defaults]
  host_key_checking = false
  inventory = inventory
  </code></pre>
  
  <p><strong>inventory/hosts:</strong></p>
  
  <pre><code>[defaults]
  machine
  </code></pre>
  
  <p><strong>inventory/group_vars/all.yaml:</strong></p>
  
  <pre><code>---
  # file: group_vars/all
  ansible_user: username
  ansible_password: password
  </code></pre>
  
  <p><strong>main.yaml:</strong></p>
  
  <pre><code>---
  
  - name: whoami
    shell: whoami
  </code></pre>
  
  <p><strong>site.yaml:</strong></p>
  
  <pre><code>---
  - hosts: machine
      roles:
          - whoami
  </code></pre>
  
  <p>if i <strong>run</strong>:</p>
  
  <pre><code>$ansible machine -i inventory/ -m shell -a "whoami"
  </code></pre>
  
  <p>it is executed <strong>successfully</strong>:</p>
  
  <pre><code>machine | SUCCESS | rc=0 &gt;&gt;
  username
  </code></pre>
  
  <p>whereas if I <strong>run</strong>:</p>
  
  <pre><code>$ansible-playbook -i inventory site.yml -v
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>fatal: [machine]: FAILED! =&gt; {
  "changed": false, 
  "failed": true, 
  "invocation": {
      "module_name": "setup"
  }, 
  "module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u1, OpenSSL 1.0.2l  25 May 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 2908\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to machine closed.\r\n", 
  "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_QAFcSD/ansible_module_setup.py\", line 134, in &lt;module&gt;\r\n    main()\r\n  File \"/tmp/ansible_QAFcSD/ansible_module_setup.py\", line 126, in main\r\n    data = get_all_facts(module)\r\n  File \"/tmp/ansible_QAFcSD/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3518, in get_all_facts\r\n  File \"/tmp/ansible_QAFcSD/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3457, in ansible_facts\r\n  File \"/tmp/ansible_QAFcSD/ansible_modlib.zip/ansible/module_utils/facts.py\", line 171, in __init__\r\n  File \"/tmp/ansible_QAFcSD/ansible_modlib.zip/ansible/module_utils/facts.py\", line 513, in get_user_facts\r\nKeyError: 'getpwnam(): name not found: username'\r\n", "msg": "MODULE FAILURE"
  }
      to retry, use: --limit @/home/username/playbook/my_ansible/site.retry
  
  PLAY RECAP *********************************************************************
  machine                       : ok=0    changed=0    unreachable=0    failed=1  
  </code></pre>