# register and looping

**URL:** <https://forum.ansible.com/t/register-and-looping/18927>\
**Category:** Ansible Project\
**Created:** [August 3, 2015, 5:06pm UTC](https://forum.ansible.com/t/register-and-looping/18927 "2015-08-03T17:06:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin\_parker](https://avatars.discourse-cdn.com/v4/letter/k/df788c/32.png) [@kevin\_parker](https://forum.ansible.com/u/kevin_parker)\
**Post date:** [August 3, 2015, 5:06pm UTC](https://forum.ansible.com/t/register-and-looping/18927/1 "2015-08-03T17:06:49Z")

</div>

i am trying to use “ipmitools” to check power status and based on the result i will start/reset the server.But i am not able to continue as register: and looping are not working .Is there any alternate approach for achieving below?

> * * *
> 
> - hosts: compute  
> gather\_facts: no  
> vars\_files:
> - input.yml
> 
> tasks:
> 
> - name: check Power status of target  
> local\_action: command ipmitool -I lanplus -H {{item.console}} -U {{item.consoleuser}} -P {{item.consolepassword}} power status  
> with\_items:
> 
> - “{{ computeserver1 }}”  
> when: item.console and item.consoleuser and item.consolepassword is defined  
> register: power
> 
> - name: check Debug  
> debug: var=power.stdout
> 
> - name: Power Reset  
> local\_action: command ipmitool -I lanplus -H {{item.console}} -U {{item.consoleuser}} -P {{item.consolepassword}} power reset  
> with\_items:
> 
> - “{{ computeserver1 }}”  
> when: item.console and item.consoleuser and item.consolepassword is defined and power.stdout.find(‘Chassis Power is on’) != -1
> 
> - name: Power On  
> local\_action: command ipmitool -I lanplus -H {{item.console}} -U {{item.consoleuser}} -P {{item.consolepassword}} power on  
> with\_items:
> 
> - “{{ computeserver1 }}”  
> when: item.console and item.consoleuser and item.consolepassword is defined and power.stdout.find(‘Chassis Power is off’) != -1

Thanks for any help

---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [August 5, 2015, 3:33am UTC](https://forum.ansible.com/t/register-and-looping/18927/2 "2015-08-05T03:33:36Z")

</div>

Can you share the structure of the “computeserver1” or even better the content of the input.yml file?

I guess you have confirmed that executing the same ipmi command from the Ansible station manually works properly?

---

<div class="post-metadata">

**Author:** ![kevin\_parker](https://avatars.discourse-cdn.com/v4/letter/k/df788c/32.png) [@kevin\_parker](https://forum.ansible.com/u/kevin_parker)\
**Post date:** [August 5, 2015, 8:20am UTC](https://forum.ansible.com/t/register-and-looping/18927/3 "2015-08-05T08:20:47Z")

</div>

**contents of input.yml**

---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [August 6, 2015, 5:31am UTC](https://forum.ansible.com/t/register-and-looping/18927/4 "2015-08-06T05:31:14Z")

</div>

Ok wrote this simple playbook just to test it:
