Hmmm... it should fail.... as the string is matched....
What happens when you do this instead?:
- name: searching the rpm into pulp repo
command: pulp-admin rpm repo content rpm --repo-id=mobi-snapshots --match
'filename={{ item }}'
loop: "{{ rpmname | default([]) }}"
register: pulpresult
when: rpmsearch is defined
ignore_errors: yes
- name: invoke failure
fail:
when: pulpresult.stdout == "\e[0m"
-R.Rao
On Wed, 3 Apr 2019 at 19:24, Kunalsing Thakur <[email protected]>
wrote:
> Can anyone help on this?
>
>
> On Wednesday, April 3, 2019 at 7:15:25 PM UTC+5:30, Kunalsing Thakur wrote:
>>
>> playbook:-
>> ---
>> - name: Deploying PCC-test
>> hosts: inplp01p2.infra.smf1.mobitv
>> gather_facts: true
>> vars_files:
>> -
>> /etc/ansible/inventories/mobitv/paytv.smf1.mobitv/group_vars/common.yaml
>> vars:
>> - rpmsearch: true
>> - rpmname:
>> - kunal
>> serial: 1
>> any_errors_fatal: true
>> roles:
>> - role: mobi_ansible_role_pulp
>>
>>
>>
>> role task:-
>> pulp.yaml
>> ---
>> - name: Logging into pulp
>> command: pulp-admin login -u admin -p admin
>> - name: searching the rpm into pulp repo
>> command: pulp-admin rpm repo content rpm --repo-id=mobi-snapshots
>> --match 'filename={{ item }}'
>> loop: "{{ rpmname | default([]) }}"
>> register: pulpresult
>> when: rpmsearch is defined
>> failed_when: pulpresult.stdout == "\e[0m"
>>
>>
>> Ansible Output:-
>> PLAY [Deploying PCC-test]
>> ****************************************************************************************
>>
>> TASK [Gathering Facts]
>> *******************************************************************************************
>> task path: /etc/ansible/playbooks/paytv/pulp.yaml:2
>> Wednesday 03 April 2019 13:44:13 +0000 (0:00:00.138) 0:00:00.138
>> *******
>> ok: [inplp01p2.infra.smf1.mobitv]
>> META: ran handlers
>>
>> TASK [mobi_ansible_role_pulp : include_tasks]
>> ********************************************************************
>> task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/main.yml:12
>> Wednesday 03 April 2019 13:44:17 +0000 (0:00:04.113) 0:00:04.252
>> *******
>> included: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml for
>> inplp01p2.infra.smf1.mobitv
>>
>> TASK [mobi_ansible_role_pulp : Logging into pulp]
>> ****************************************************************
>> task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:2
>> Wednesday 03 April 2019 13:44:18 +0000 (0:00:00.452) 0:00:04.705
>> *******
>> changed: [pulpnode] => changed=true
>> cmd:
>> - pulp-admin
>> - login
>> - -u
>> - admin
>> - -p
>> - admin
>> delta: '0:00:01.103429'
>> end: '2019-04-03 13:44:20.453693'
>> rc: 0
>> start: '2019-04-03 13:44:19.350264'
>> stderr: ''
>> stderr_lines: []
>> stdout: |-
>> [0m[92mSuccessfully logged in. Session certificate will expire at Apr
>> 10 13:44:20 2019
>> GMT.[0m
>> stdout_lines: <omitted>
>>
>> TASK [mobi_ansible_role_pulp : searching the rpm into pulp repo]
>> *************************************************
>> task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:4
>> Wednesday 03 April 2019 13:44:20 +0000 (0:00:02.181) 0:00:06.887
>> *******
>> changed: [pulpnode] => (item=kunal) => changed=true
>> cmd:
>> - pulp-admin
>> - rpm
>> - repo
>> - content
>> - rpm
>> - --repo-id=mobi-snapshots
>> - --match
>> - filename=kunal
>> delta: '0:00:01.359062'
>> end: '2019-04-03 13:44:22.679585'
>> failed_when_result: false
>> item: kunal
>> rc: 0
>> start: '2019-04-03 13:44:21.320523'
>> stderr: ''
>> stderr_lines: []
>> stdout: "\e[0m"
>> stdout_lines: <omitted>
>> META: ran handlers
>> META: ran handlers
>>
>> PLAY RECAP
>> *******************************************************************************************************
>> inplp01p2.infra.smf1.mobitv : ok=4 changed=2 unreachable=0
>> failed=0
>>
>> Wednesday 03 April 2019 13:44:22 +0000 (0:00:02.150) 0:00:09.037
>> *******
>>
>> ===============================================================================
>> Gathering Facts
>> -------------------------------------------------------------------------------------------
>> 4.11s
>> /etc/ansible/playbooks/paytv/pulp.yaml:2
>> ------------------------------------------------------------------------
>> mobi_ansible_role_pulp : Logging into pulp
>> ---------------------------------------------------------------- 2.18s
>> /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:2
>> -----------------------------------------------------
>> mobi_ansible_role_pulp : searching the rpm into pulp repo
>> ------------------------------------------------- 2.15s
>> /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:4
>> -----------------------------------------------------
>> mobi_ansible_role_pulp : include_tasks
>> -------------------------------------------------------------------- 0.45s
>> /etc/ansible/roles/mobi_ansible_role_pulp/tasks/main.yml:12
>> -----------------------------------------------------
>> Playbook run took 0 days, 0 hours, 0 minutes, 9 seconds
>>
>>
>>
>>
>> It should fail the task not pass?
>>
>> --
> 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/070b0841-54b9-4883-b605-0686a135d127%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/070b0841-54b9-4883-b605-0686a135d127%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAKbF63j4Lja2ESEYA-4aNdjNyjAPh99Uq54CghLc7QHWoLjitw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.