# Need an assist for an ansible playbook where is am receiving error while comparing ansible value with the customer provided value.

**URL:** <https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185>\
**Category:** Ansible Project\
**Created:** [January 10, 2022, 4:33am UTC](https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185 "2022-01-10T04:33:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marian\_Saldhana](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@Marian\_Saldhana](https://forum.ansible.com/u/Marian_Saldhana)\
**Post date:** [January 10, 2022, 4:33am UTC](https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185/1 "2022-01-10T04:33:00Z")

</div>

Hi All,

I need to work on ansible role, where after the ansible module is executed I need to compare that value with the value provided by the customer.  
I am able to fetch the value through ansible role however I am facing issues while comparing this value with the value provided by the customer.  
Any assistance or guidance would be of great help, Thanks.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 10, 2022, 5:46am UTC](https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185/2 "2022-01-10T05:46:14Z")

</div>

This is correct, as the values are different. So the assert task should fail.

---

<div class="post-metadata">

**Author:** ![Marian\_Saldhana](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@Marian\_Saldhana](https://forum.ansible.com/u/Marian_Saldhana)\
**Post date:** [January 10, 2022, 5:48am UTC](https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185/3 "2022-01-10T05:48:15Z")

</div>

Thanks for your reply. I modified the command ( timedatectl | grep -i “Time zone:” | sed ‘s/^ \*.T/T/g’ ) to trim the space I was receiving in stdout and it resolved the issue.

---

<div class="post-metadata">

**Author:** ![Diptajeet\_Khan](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@Diptajeet\_Khan](https://forum.ansible.com/u/Diptajeet_Khan)\
**Post date:** [January 10, 2022, 7:17am UTC](https://forum.ansible.com/t/need-an-assist-for-an-ansible-playbook-where-is-am-receiving-error-while-comparing-ansible-value-with-the-customer-provided-value/36185/4 "2022-01-10T07:17:18Z")

</div>

Your last task shall not match due to whitespaces from the registered var. Try rewriting your assertion like this.

- name: “Assert Similarity”

vars:

customer\_val: “{{ lookup(‘file’, ‘customer-expects.txt’) | from\_yaml }}”

assert:

that: “{{ customer\_val == \_cat.stdout | trim }}”

fail\_msg: Missed

success\_msg: Matched

PS: Update the formatting as required, am not using a console/system.
