2
votes

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).

2
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

2 Answers

4
votes

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.

0
votes

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