# simple problem has me stumped

**URL:** <https://forum.ansible.com/t/simple-problem-has-me-stumped/32194>\
**Category:** Ansible Project\
**Created:** [February 10, 2020, 9:18pm UTC](https://forum.ansible.com/t/simple-problem-has-me-stumped/32194 "2020-02-10T21:18:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Walsh](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@Tony\_Walsh](https://forum.ansible.com/u/Tony_Walsh)\
**Post date:** [February 10, 2020, 9:18pm UTC](https://forum.ansible.com/t/simple-problem-has-me-stumped/32194/1 "2020-02-10T21:18:24Z")

</div>

I have a simple scenario that fails, but I can’t figure out why. Here’s the command line invocation and the result:

[root@cluster-mgmt tasks]# ansible-playbook -i ./hosts main.yml

PLAY [CLUSTERS team downtime orchestration play] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [set nagios downtime] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘myTestVar’ is undefined\n\nThe error appears to have been in ‘/autofs/nccs-svm1\_home1/tw58/SANDBOX/ANSIBLE\_VARDIR/testVar/tasks/main.yml’: line 9, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: set nagios downtime\n ^ here\n”}  
[WARNING]: Could not create retry file ‘/autofs/nccs-svm1\_home1/tw58/SANDBOX/ANSIBLE\_VARDIR/testVar/tasks/main.retry’. [Errno 13] Permission denied:  
u’/autofs/nccs-svm1\_home1/tw58/SANDBOX/ANSIBLE\_VARDIR/testVar/tasks/main.retry’

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=1 changed=0 unreachable=0 failed=1

The playbook is simple:

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 10, 2020, 10:28pm UTC](https://forum.ansible.com/t/simple-problem-has-me-stumped/32194/2 "2020-02-10T22:28:18Z")

</div>

You're mixing the concepts of a "Role"  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_reuse\_roles.html#roles](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#roles)  
and a "Playbook"  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks.html)

1) Move the directory "testVar" into the directory "roles". Remove "hosts" and  
"ansible.cfg" from the role and put them into the current directory.

├── playbook.yml  
├── hosts  
├── ansible.cfg  
├── roles  
│ └── testVar

[root@cluster-mgmt testVar]# tree  
├── defaults  
│ └── main.yml  
├── files  
├── handlers  
│ └── main.yml  
├── meta  
│ └── main.yml  
├── README.md  
├── tasks  
│ └── main.yml  
├── templates  
├── tests  
│ ├── inventory  
│ └── test.yml  
└── vars  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── main.yml

2) Make sure "ansible.cfg" points to the roles

&nbsp;&nbsp;$ grep roles ansible.cfg  
&nbsp;&nbsp;roles\_path = $PWD/roles

3) Create playbook.yml

&nbsp;&nbsp;- hosts: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;name: CLUSTERS team downtime orchestration play  
&nbsp;&nbsp;&nbsp;&nbsp;gather\_facts: true  
&nbsp;&nbsp;&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- testVar

4) Remove the playbook directives from roles/testVar/tasks/main.yml

&nbsp;&nbsp;# tasks file for testVar  
&nbsp;&nbsp;- name: set nagios downtime  
&nbsp;&nbsp;&nbsp;&nbsp;debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "the value of the variable {{ myTestVar }}"

5) Now the command should work

&nbsp;&nbsp;$ ansible-playbook -i hosts -c ansible.cfg playbook.yml

HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Tony\_Walsh](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@Tony\_Walsh](https://forum.ansible.com/u/Tony_Walsh)\
**Post date:** [February 11, 2020, 3:13pm UTC](https://forum.ansible.com/t/simple-problem-has-me-stumped/32194/3 "2020-02-11T15:13:14Z")

</div>

Ah,

now I see what you mean - got it working! Thanks so much for the hand!

kind regards,  
T
