# ansible variable in number

**URL:** <https://forum.ansible.com/t/ansible-variable-in-number/32416>\
**Category:** Ansible Project\
**Created:** [March 8, 2020, 6:54am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416 "2020-03-08T06:54:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeungJoon](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SeungJoon](https://forum.ansible.com/u/SeungJoon)\
**Post date:** [March 8, 2020, 6:54am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416/1 "2020-03-08T06:54:30Z")

</div>

I want to put the numbers 1 to 10 in the {{}} variable but it fails

How to put numbers from 1 to 10 in a variable

The condition does not use with\_item

playbook example :

- name: Alarm check

when: ‘“{{ }} alarms currently active” in host.stdout’  
debug: msg=“{{ inventory\_hostname }}:Alarm is nomal”  
register: result\_alarm

Thank you regard

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [March 8, 2020, 7:00am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416/2 "2020-03-08T07:00:26Z")

</div>

> I want to put the numbers 1 to 10 in the {{}} variable but it fails
> 
> How to put numbers from 1 to 10 in a variable
> 
> The condition does not use with\_item
> 
> playbook example :  
> - name: Alarm check  
> when: '"{{ }} alarms currently active" in host.stdout'  
> debug: msg="{{ inventory\_hostname }}:Alarm is nomal"  
> register: result\_alarm
> 
> Thank you regard

Can you please elaborate on the objectives of the task? What are the contents of host.stdout?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![SeungJoon](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SeungJoon](https://forum.ansible.com/u/SeungJoon)\
**Post date:** [March 8, 2020, 7:09am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416/3 "2020-03-08T07:09:40Z")

</div>

The contents of host.stdout is this No alarms currently active

“1 alarms currently active”  
“No alarms currently active”

Regards

---

<div class="post-metadata">

**Author:** ![SeungJoon](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SeungJoon](https://forum.ansible.com/u/SeungJoon)\
**Post date:** [March 8, 2020, 7:10am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416/4 "2020-03-08T07:10:30Z")

</div>

The contents of host.stdout is this No alarms currently active

“1 alarms currently active”

“No alarms currently active”

---

<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:** [March 8, 2020, 7:17am UTC](https://forum.ansible.com/t/ansible-variable-in-number/32416/5 "2020-03-08T07:17:38Z")

</div>

If you are trying to find out if there are any alarm for this host,  
then use regex search:

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_tests.html#testing-strings](https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings)
