simple problem has me stumped

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:

You're mixing the concepts of a "Role"
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

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
     └── main.yml

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

  $ grep roles ansible.cfg
  roles_path = $PWD/roles

3) Create playbook.yml

  - hosts: localhost
    name: CLUSTERS team downtime orchestration play
    gather_facts: true
    roles:
      - testVar

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

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

5) Now the command should work

  $ ansible-playbook -i hosts -c ansible.cfg playbook.yml

HTH,

  -vlado

Ah,

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

kind regards,
T