Change password using script

Hi guys,

I kinda feel ashamed asking this kind of questions but I'm currently
still learning Ansible, only started a week ago and I have to complete
this as a part of a personal project that I will present.

I wrote a simple playbook for changing passwords on linux systems,
will have to add module for windows later but now the issue is with
AIX systems.
User module isn't working for AIX, I tried things from internet but no
success so I wrote a script that changes the password on AIX with 2
arguments, user and password---> as a result the password is changed
for that user.
What I have to do in the playbook is to run copy and run this script
on the remote server with the password and user that I give give using
-e when the remote system is AIX:

- name: User configuration
  remote_user: root
  hosts: "{{ hosts }}"

  tasks:
    - name: Password change Linux
      user:
        name: root
        state: present
        update_password: always
        password: "{{ admin_password | password_hash('sha512') }}"
        shell: /bin/bash

    - name: Copy pw change script AIX
      copy:
        src: /root/docker/centos7-ansible/chpas.sh
        dest: /tmp/chpas.sh
        mode: 0777
      register: script_copy
      when: ansible_distribution == 'AIX'

    - name: Execute pw change AIX script
      command: /tmp/chpas.sh root "{{ admin_password }}"
      when: (ansible_distribution == 'AIX') and
            (script_copy.rc == 1)
      register: script_execute

    - name: Clear files
      file:
        path: '/tmp/chpas.sh'
        state: absent
      when: (ansible_distribution == 'AIX') and
            (script_execute.rc== 1)

the error is :

TASK [Gathering Facts]

(attachments)

chpass.yml (895 Bytes)

Issue solved, used "is succeeded" for validation instead of rc == 1

Still could use if i found out what's wrong with using rc since the
syntax is the same as on ansible website

Most modules doesn't return rc and copy is one of them
https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#rc

You can always use this to show what a module is returning.

- debug: var=<variable name>

Thanks Kai, I searched for more information on rc but the
documentation is poor. Thank you for the information!