0

My playbook has no issues when running it on the command line. But in ansible controller, I am encountering this error:

[WARNING]: Found variable using reserved name: vars_files

ERROR! vars file /var/lib/awx/projects/Windows/roles/create/vars/appendvars.yml was not found
Could not find file on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

This is my playbook path:

/var/lib/awx/projects/Windows/playbook.yml

My playbook:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

Each of these vars_files contain the variables and their corresponding values, for me to reference the variable name in my playbook tasks.

I have already seen this question, ERROR! vars file vars not found on the Ansible Controller , but I am still unable to resolve my issue.

In the 'variables' section of Ansible Controller, I have already tried these:

vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - appendvars.yml
  - appendvars.yml
vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml
  - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

But I still get the exact same error message. What and where do I need to change to fix this error?

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
Blitzden
  • 159
  • 7
  • 1
    What is for you the difference between _"run in the command line"_ and _"on the controller"_? – β.εηοιτ.βε Jun 26 '23 at 13:56
  • 2
    Also, have you defined a variable named `vars_files` in either _roles/Create/vars/appendvars.yml_ or _roles/Delete/vars/appendvars.yml_? As this is what your playbook are compiling about too. – β.εηοιτ.βε Jun 26 '23 at 13:58
  • 2
    Last but not least, are you aware that variables in the _vars/main.yml_ folder of a role are automatically loaded along the role and that this is probably what you should do here? Ref: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-directory-structure – β.εηοιτ.βε Jun 26 '23 at 14:00
  • `What is the correct path for vars_files in ansible controller?` => An Ansible controller being any server/VM/container/environment/python virtualenv/specific ci or automatization platform/... where your playbook runs, the correct path is the one where you have made that file available in your particular given situation. Please read [ask] paying attention to the [mre] section. – Zeitounator Jun 27 '23 at 06:34
  • Also, please use tags appropriately. Read their descriptions and apply only if they are directly related to the issue in your question. I left the ambiguous ones (`var` and `variables`) that you should still review. But I removed `controller` which has nothing to do with the concept of Ansible controller. Thanks – Zeitounator Jun 27 '23 at 06:42

1 Answers1

0

Based on @β.εηοιτ.βε 's suggestions,

In /roles/Create/vars/main.yml, I removed:

vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

which was causing the warning: "[WARNING]: Found variable using reserved name: vars_files", and replaced it with all the variables from /roles/Create/vars/appendvars.yml

Did the same for the 'Delete' role too.

Correct playbook:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete
Blitzden
  • 159
  • 7