Hi Brian,
I have registered results. i am able to access the content using
pulp.results.[0].stdout. if nothing is found stdout prints this "\e[0m".
And i want to compare this string to failed the task using failed_when
condition.
but somehow it gives me below error.
fatal: [pulp]: FAILED! =>
  msg: 'The conditional check ''pulp.results.[0].stdout == "\e[0m"''
failed. The error was: template error while templating string: expected
name or number. String: {% if pulp.results.[0].stdout == "\e[0m" %} True {%
else %} False {% endif %}'


Playbook:-
---
- name: Deploying PCC-test
  hosts: pulp
  gather_facts: true
  vars_files:
    - /etc/ansible/inventories/mobitv/group_vars/common.yaml
  vars:
    - rpmsearch: true
    - rpmname:
        - mobi-auth-manager-5.42.0-2019h
  serial: 1
  any_errors_fatal: true
  roles:
    - role: mobi_ansible_role_pulp

role-task:-
---
- name: Logging into pulp
  shell: pulp-admin login -u admin -p admin
- name: searching the rpm into pulp repo
  shell: pulp-admin rpm repo content rpm --repo-id=mobi-snapshots --match
'filename={{ item }}'
  with_items: "{{ rpmname | default([]) }}"
  register: pulp
  when: rpmsearch is defined
  failed_when: pulp.results.[0].stdout == "\e[0m"
- debug:
    var: pulp.results.0.stdout

Results:-
PLAY [Deploying PCC-test]
***************************************************************************************

TASK [Gathering Facts]
******************************************************************************************
task path: /etc/ansible/playbooks/paytv/pulp.yaml:2
Thursday 04 April 2019  06:24:44 +0000 (0:00:00.139)       0:00:00.139
********
ok: [pulp]
META: ran handlers

TASK [mobi_ansible_role_pulp : include_tasks]
*******************************************************************
task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/main.yml:12
Thursday 04 April 2019  06:24:48 +0000 (0:00:03.441)       0:00:03.580
********
included: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml for pulp

TASK [mobi_ansible_role_pulp : Logging into pulp]
***************************************************************
task path: /etc/ansible/roles/mobi_ansible_role_pulp/tasks/pulp.yaml:2
Thursday 04 April 2019  06:24:48 +0000 (0:00:00.485)       0:00:04.066
********
changed: [pulp] => changed=true
  cmd: pulp-admin login -u admin -p admin
  delta: '0:00:01.067098'
  end: '2019-04-04 06:24:50.812519'
  rc: 0
  start: '2019-04-04 06:24:49.745421'
  stderr: ''
  stderr_lines: []
  stdout: |-
    [0m[92mSuccessfully logged in. Session certificate will expire at Apr
11 06:24:50 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
Thursday 04 April 2019  06:24:50 +0000 (0:00:02.175)       0:00:06.241
********
fatal: [pulp]: FAILED! =>
  msg: 'The conditional check ''pulp.results.[0].stdout == "\e[0m"''
failed. The error was: template error while templating string: expected
name or number. String: {% if pulp.results.[0].stdout == "\e[0m" %} True {%
else %} False {% endif %}'

NO MORE HOSTS LEFT
**********************************************************************************************
        to retry, use: --limit @/etc/ansible/playbooks/paytv/pulp.retry

PLAY RECAP
******************************************************************************************************
pulp : ok=3    changed=1    unreachable=0    failed=1



Any help will be much appreciated.


On Thu, Apr 4, 2019 at 1:13 AM Brian Coca <[email protected]> wrote:

> results only exists if you registered in a loop
>
> --
> ----------
> Brian Coca
>
> --
> 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/CACVha7ec-JCvmHLeMW%2BAjFUWqu4J9bnP6-uMh0oD5e-vU8k8iA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


[image: --]

kunalsing thakur
[image: https://]about.me/kunalsingthakur
<https://about.me/kunalsingthakur?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>

-- 
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/CANErU6n1oemLSYCJTKvpVJNGwJ8FwG5%3DGtZVZZM4Da-wYawz2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to