ansible variable in number

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

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
        Racke

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

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

Regards

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

“1 alarms currently active”

“No alarms currently active”

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