title: Ansible-playbook :change account password for multiple different user in 100 nos of linux servers
body: <p>i Need to change a couple of account passwords, for example for testuser1 and testuser2,testuser3. however, from the 100+ systems I have, not all of them have both users on them. Some systems have test_user1 and some have test_user2 and sometimes both or none of them.</p>
  
  <p>This is when I start having issues; I created the following playbook below :- </p>
  
  <pre><code>---
  - name: Set Password
    hosts: test
    user: admin1
    become: yes
    ignore_errors: yes
  
    tasks:
    - shell: getent passwd testuser1 | wc -l | tr -d ' '
      register: user_exists_testuser1
      ignore_errors: yes
  
    - name: change password for testuser1
      user: name=testuser1 update_password=always 
      password="$1$3Zdze7Vx$ltv6dIsdfrsD7."
      when: user_exists_testuser1.rc == 0
  
    - shell: getent passwd testuser2 | wc -l | tr -d ' '
      register: user_exists_testuser2
      ignore_errors: yes
  
    - name: change password for testuser2
      user: name=testuser2 update_password=always 
      password="$1$sfddgv6dIxsdfssNt2D4."
      when: user_exists_root.rc == 0
  
    - shell: getent passwd testuser3 | wc -l | tr -d ' '
      register: user_exists_testuser3
      ignore_errors: yes
  
    - name: change password for testuser3
      user: name=testuser3 update_password=always 
      password="$1$3Zdze7VxDEFv6dHKHKSSt2D3."
      when: user_exists_adminusr.rc == 0
  </code></pre>
  
  <p><strong>issue on this script :</strong>  <strong>if the user does not exist on the system, it creates it. Is there any way to avoid the creation of the user?</strong> </p>
  
  <p>but password is updating correctly in all servers.can have help on this better code change on this above playbook .</p>