Still could use if i found out what's wrong with using rc since the syntax is the same as on ansible website
On Tue, Jan 29, 2019 at 8:32 PM boncalo mihai <[email protected]> wrote: > > Issue solved, used "is succeeded" for validation instead of rc == 1 > > On Tue, Jan 29, 2019 at 6:26 PM boncalo mihai <[email protected]> wrote: > > > > 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] > > *************************************************************************************************************************************************************************************** > > ok: [ansible_aix] > > > > TASK [Password change Linux] > > ********************************************************************************************************************************************************************************* > > changed: [ansible_aix] => {"append": false, "changed": true, > > "comment": "", "group": 0, "home": "/root", "move_home": false, > > "name": "root", "password": "NOT_LOGGING_PASSWORD", "shell": > > "/bin/bash", "state": "present", "uid": 0} > > > > TASK [Copy pw change script AIX] > > ***************************************************************************************************************************************************************************** > > ok: [ansible_aix] => {"changed": false, "checksum": > > "d434aee957d8a46a41f92f76936ebcf53848dc1b", "dest": "/tmp/chpas.sh", > > "gid": 0, "group": "system", "mode": "0777", "owner": "root", "path": > > "/tmp/chpas.sh", "size": 458, "state": "file", "uid": 0} > > > > TASK [Execute pw change AIX script] > > ************************************************************************************************************************************************************************** > > fatal: [ansible_aix]: FAILED! => {"msg": "The conditional check > > '(ansible_distribution == 'AIX') and (script_copy.rc == 1)' failed. > > The error was: error while evaluating conditional > > ((ansible_distribution == 'AIX') and (script_copy.rc == 1)): 'dict > > object' has no attribute 'rc'\n\nThe error appears to have been in > > '/root/docker/centos7-ansible/chpass.yml': line 22, column 7, but > > may\nbe elsewhere in the file depending on the exact syntax > > problem.\n\nThe offending line appears to be:\n\n\n - name: Execute > > pw change AIX script\n ^ here\n"} > > to retry, use: --limit @/root/docker/centos7-ansible/chpass.retry > > > > PLAY RECAP > > *************************************************************************************************************************************************************************************************** > > ansible_aix : ok=3 changed=1 unreachable=0 failed=1 > > > > Attached the yml file since I don't think the code is well aligned after > > paste. > > > > Thank you very much, > > Mihai. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAOK917Q5G6i-Dd0zh1f8A_TkVXd%2Bu8otNgvdxGk0fjxf7etjjw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
