Running Vagrant multi-host with CentOS7 as an Ansible controller and few Linux distro clients for testing Ansible playbooks.

Have NFS shared files mounting at /vagrant/ on the Cent7 Ansible controller. The ansible.cfg shows roles as /vagrant/Ansible/roles originally.

Calling the role... Going through the tasks/main.yml and reaches an include_tasks: some_yaml_file.yml which is a loop over a block of tasks.

Basically, it is an include_tasks which calls a "block" of tasks via another file as that is the cleanest way to iterate over the variable as I understand the nested loop over a block structure. Also, import cannot do such in testing that scenario.

- name: "Iterate over crontab files."
    include_tasks: ./tasks/crontab_files.yml
    loop: "{{ user_data }}"

Notice the ./tasks/ in the path. That is not relative to the file but makes the error returned match the path accurately. I've tried numerous variations with no luck including the full path on disk.

That said, the task functionality works fine as two simple playbooks with the variables defined. However, in the role it errors out with a message about not able to find the "included" playbook.

Playing with various path'ing and the trailing slash added to:
roles_path = /vagrant/Ansible/roles/
it finally maps the path correctly on the disk:
/vagrant/Ansible/roles/adim/tasks/crontab_files.yml to where the file resides.

Still errors out with:

FAILED! => {"reason": "Could not find or access '/vagrant/Ansible/roles/adim/tasks/crontab_files.yml' on the Ansible Controller."}

What am I missing or doing wrong?

Thank you for the help & feedback!

1 Answer 1


The include_task is relative to the position of the role tasks folder. You have the following structure


In your main.yml of the role you need to define the location relative to main.yml.

- name: "Iterate over crontab files."
  include_tasks: crontab_files.yml
  loop: "{{ user_data }}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .