4

ERROR! vars file vars not found on the Ansible Controller. If you are using a module and expect the file to exist on the remote, see the remote_src option.

---
# tasks file for user-management
- hosts: linux
  become: yes
  vars_files:
    - vars/active-users
    - vars/remove-users
  roles:
    - { role: user-management }
  tasks:
    - import_tasks: /tasks/user-accounts.yml
    - import_tasks: /tasks/authorized-key.yml

Trying to run the main.yml on a server to execute on remote hosts (linux). The vars playbook in the vars directory has two playbooks (active-users, remove-users).

kaushik
  • 41
  • 1
  • 1
  • 3
  • 1
    The error you are reporting comes from a task using the `copy` module that we cannot see here. It is just reporting it cannot find a file on your control machine. – Zeitounator Jun 13 '19 at 03:15

4 Answers4

9

Your vars folder should be at the same level than your playbook. If yes would it be possible that you missed .yml extension of your active-users and remove-users.

Porzio Jonathan
  • 536
  • 2
  • 13
1

Check the relative path this way:

  vars_files:
    - ../vars/active-users.yaml
    - ../vars/remove-users.yaml
MoYaMoS
  • 31
  • 1
  • 5
0

I was stuck at the same error, issue I found was that my vars_files's location defined in the playbook was incorrect. Steps I followed :- 1> run #find / name | grep <vars_files>.yaml # this command is going to run search for your <vars_files>.yaml starting from the root directory; check location of the vars_files. 2> make sure location of the vars files in the playbook match with the step1.

for instance:-

   hosts: localhost
   connection: local
   gather_facts: no
   become: yes
   vars_files:
   - /root/secrets.yaml
0

@MoYaMoS, Thanks! This was the resolution for me. It wasn't obvious at first as I have a top level play calling two plays in the play/ directory. The domain-join play is the one that calls group_vars in this case.

├── group_vars
│   └── linux
├── plays
│   ├── create-vm.yml
│   └── domain-join.yml
└── provision.yml

I just specified the relative path in the domain-join.yml as you mentioned. Works perfectly.

  vars_files:
    - ../group_vars/linux
HBach
  • 31
  • 1
  • 7