title: Change linux password with Ansible playbook script when connecting as a non-root user without sudo privileges
body: <p>I am trying to change password for a <strong>non-root</strong> Linux user from Ansible playbook.
  To do so I tried to follow <a href="https://www.systutorials.com/39549/changing-linux-users-password-in-one-command-line/" rel="nofollow noreferrer">this link</a></p>
  
  <p>Following the instruction I can successfully change the password of a non-root user by typing the code below in the terminal.</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ echo -e "your_current_pass\nlinuxpassword\nlinuxpassword" | passwd
  Changing password for testuser.
  (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
  </code></pre>
  
  <p>After that I am trying to automate the code with an Ansible playbook like below,</p>
  
  <pre class="lang-yaml prettyprint-override"><code>---
  - hosts: all
    gather_facts: no
  
    tasks:
      - name: "Check if user exists"
        register: user1_exists
        raw: getent passwd {{ ansible_user }}
        ignore_errors: true
  
      - name: "Change {{ ansible_user }} password"
        raw: echo -e "my_current_pass\nmy_new_pass\nmy_new_pass" | passwd
        when: user1_exists|success
  </code></pre>
  
  <p>I am using the <a href="http://docs.ansible.com/ansible/latest/raw_module.html" rel="nofollow noreferrer">raw module</a> of Ansible here as most of my machines don't have Python installed. I do not have <code>superuser (sudo)</code> permission either to use <code>become: True</code> in playbook.</p>
  
  <p>Also using <strong>password based authentication</strong> here to run the Ansible playbook on target machine. Not ssh based authentication.</p>
  
  <p>But while I am executing the playbook I am getting this error,</p>
  
  <pre><code>TASK [change user1 password] ***************************************************
  fatal: [192.168.0.57]: FAILED! =&gt; {"changed": true, "failed": true, "rc": 10, 
  "stderr": "Shared connection to 192.168.0.57 closed.\r\n", "stdout": "Changing 
  password for testuser.\r\n(current) UNIX password: passwd: Authentication 
  token manipulation error\r\npasswd: password unchanged\r\n", "stdout_lines": 
  ["Changing password for testuser.", "(current) UNIX password: passwd: 
  Authentication token manipulation error", "passwd: password unchanged"]}
  </code></pre>
  
  <p>Could anyone show me the mistakes I am making here?</p>