# Idiot check on how register: is supposed to work?

**URL:** <https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [June 27, 2017, 2:11am UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826 "2017-06-27T02:11:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobby.kuzma](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@bobby.kuzma](https://forum.ansible.com/u/bobby.kuzma)\
**Post date:** [June 27, 2017, 2:11am UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826/1 "2017-06-27T02:11:16Z")

</div>

Hello all,

I’m _very_ new to ansible, and hope that this is something very simple that has escaped me.

Here’s what I’m trying to accomplish: I’m doing a task on prior runs that shouldn’t be repeated, so I’m dropping a flag on the system to pick up on future playbook runs.

- name: Check for prior execution win\_stat: path: c:\temp\dc.success register: file\_flag - name: Debug Check debug: var: file\_flag

TASK [Check for prior execution] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/ctfadmin/MOONLIGHTWALK/ansible/playbooks/dc1\_corp.stage0.yml:61  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win\_stat.ps1  
\<[172.16.1.50](https://l.facebook.com/l.php?u=http%3A%2F%2F172.16.1.50%2F&h=ATNP7PZJuawiLs1Hi_NtuR1_ptIQDmH8hsaItwmxsoFNheToML2BpIF735wHccNAov6NaxdkSG1frXTJehFLbof1DHnclFk7PdPBKEvkumgNWebmRHs0dCNY7JutGq2oxsK0hAN4lKaMLw)\> ESTABLISH WINRM CONNECTION FOR USER: ansible on PORT 5985 TO [172.16.1.50](https://l.facebook.com/l.php?u=http%3A%2F%2F172.16.1.50%2F&h=ATNP7PZJuawiLs1Hi_NtuR1_ptIQDmH8hsaItwmxsoFNheToML2BpIF735wHccNAov6NaxdkSG1frXTJehFLbof1DHnclFk7PdPBKEvkumgNWebmRHs0dCNY7JutGq2oxsK0hAN4lKaMLw)  
EXEC (via pipeline wrapper)  
ok: [[172.16.1.50](https://l.facebook.com/l.php?u=http%3A%2F%2F172.16.1.50%2F&h=ATNP7PZJuawiLs1Hi_NtuR1_ptIQDmH8hsaItwmxsoFNheToML2BpIF735wHccNAov6NaxdkSG1frXTJehFLbof1DHnclFk7PdPBKEvkumgNWebmRHs0dCNY7JutGq2oxsK0hAN4lKaMLw)] =\> {  
“changed”: false,  
“stat”: {  
“attributes”: “Archive”,  
“checksum”: “da39a3ee5e6b4b0d3255bfef95601890afd80709”,  
“creationtime”: 1498507211.5576174,  
“exists”: true,  
“extension”: “.success”,  
“filename”: “dc.success”,  
“isarchive”: true,  
“isdir”: false,  
“ishidden”: false,  
“islnk”: false,  
“isreadonly”: false,  
“isshared”: false,  
“lastaccesstime”: 1498507211.5576174,  
“lastwritetime”: 1498508973.9960954,  
“md5”: “d41d8cd98f00b204e9800998ecf8427e”,  
“owner”: “BUILTIN\Administrators”,  
“path”: “C:\temp\dc.success”,  
“size”: 0  
}  
}

TASK [Debug Check] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/ctfadmin/MOONLIGHTWALK/ansible/playbooks/dc1\_corp.stage0.yml:65  
ok: [[172.16.1.50](https://l.facebook.com/l.php?u=http%3A%2F%2F172.16.1.50%2F&h=ATNP7PZJuawiLs1Hi_NtuR1_ptIQDmH8hsaItwmxsoFNheToML2BpIF735wHccNAov6NaxdkSG1frXTJehFLbof1DHnclFk7PdPBKEvkumgNWebmRHs0dCNY7JutGq2oxsK0hAN4lKaMLw)] =\> {  
“file\_flag”: “VARIABLE IS NOT DEFINED!”  
}

I’m hoping that someone can point out a simple an obvious thing that I’m missing!

Thank you in advance!

-Bobby

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [June 27, 2017, 2:39am UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826/2 "2017-06-27T02:39:22Z")

</div>

Take a look at the stat module. It has slightly better examples of what you are trying to do: [http://docs.ansible.com/ansible/stat\_module.html](http://docs.ansible.com/ansible/stat_module.html)

---

<div class="post-metadata">

**Author:** ![Daniel\_JD](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Daniel\_JD](https://forum.ansible.com/u/Daniel_JD)\
**Post date:** [June 27, 2017, 6:25am UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826/3 "2017-06-27T06:25:52Z")

</div>

I think your indention is wrong.

You have

- name: Check for prior execution win\_stat: path: c:\temp\dc.success register: file\_flag

It should be:

- name: Check for prior execution win\_stat: path: c:\temp\dc.success register: file\_flag

---

<div class="post-metadata">

**Author:** ![bobby.kuzma](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@bobby.kuzma](https://forum.ansible.com/u/bobby.kuzma)\
**Post date:** [June 27, 2017, 12:20pm UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826/4 "2017-06-27T12:20:52Z")

</div>

I double-checked my test case, and I can can confirm that the indentation is as you suggest, where the register: is aligned with the win\_stat. Copying and pasting didn’t work out so well in the post :-/

---

<div class="post-metadata">

**Author:** ![Mehdi\_B](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@Mehdi\_B](https://forum.ansible.com/u/Mehdi_B)\
**Post date:** [June 29, 2017, 8:54am UTC](https://forum.ansible.com/t/idiot-check-on-how-register-is-supposed-to-work/24826/5 "2017-06-29T08:54:18Z")

</div>

Hi,

file\_flag is not a variable but a json structure

see the doc for stat:

[http://docs.ansible.com/ansible/win\_stat\_module.html](http://docs.ansible.com/ansible/win_stat_module.html)

you should instead use

var: file\_flag.stat.checksum

M B
