Hello Team,
When i was checking for string comparison in failed_when condition.
the ansible task does not give any output if search is not found. but it
will print stdout variable as stdout: "\e[0m"
But when i try to compare my ansible playbook gives error.
I tried two ways in codition:-
1) failed_when: "'{{\e[0m}}' in pulp.results.[0].stdout"
Error which i got:-
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:55:59 +0000 (0:00:02.078) 0:00:06.052
********
fatal: [pulp]: FAILED! =>
msg: "The conditional check ''{{\e[0m}}' in pulp.results.[0].stdout'
failed. The error was: template error while templating string: unexpected
char u'\\x1b' at 3. String: '{{\e[0m}}' in pulp.results.[0].stdout"
2)failed_when: pulp.results.[0].stdout == "{{\e[0m}}"
fatal: [inplp01p2.infra.smf1.mobitv]: FAILED! =>
msg: |-
The conditional check 'pulp.results.[0].stdout == "{{\e[0m}}"' failed.
The error was: unexpected char u'\\' at 30
line 1
task:-
---
- 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:
- mobi-auth-manager-5.42.0-2019h
serial: 1
any_errors_fatal: true
roles:
- role: mobi_ansible_role_pulp
role:-
---
- 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: "'{{\e[0m}}' in pulp.results.[0].stdout"
- debug:
var: pulp.results.0.stdout
--
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/a5dcac1e-e00b-4dee-80b9-49fd64fe894f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.