# Setting task path

**URL:** <https://forum.ansible.com/t/setting-task-path/36553>\
**Category:** Ansible Project\
**Created:** [April 21, 2022, 6:47pm UTC](https://forum.ansible.com/t/setting-task-path/36553 "2022-04-21T18:47:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [April 21, 2022, 6:47pm UTC](https://forum.ansible.com/t/setting-task-path/36553/1 "2022-04-21T18:47:43Z")

</div>

My current ansible playbook and roles are under /etc/Ansiblectrl01

When I try to build a new VM, using:

ansible-playbook playbooks/newvm.yaml -e “hostname=xxx” -vvvv

From:

/etc/Ansiblectrl01, it errors:

fatal: [localhost]: FAILED! =\> {  
“ansible\_facts”: {  
“server”: {}  
},  
“ansible\_included\_var\_files”: ,  
“changed”: false,  
“message”: “Could not find or access ‘/etc/ansible/servers/USAEDSADMP01.yaml’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote\_src option”  
}

It seems to be reading the yaml file from the wrong old location for some reason /etc/ansible.

How can I fix this?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 21, 2022, 7:30pm UTC](https://forum.ansible.com/t/setting-task-path/36553/2 "2022-04-21T19:30:47Z")

</div>

include\_vars ONLY runs on the controller, not the remote, you'll have  
to fetch/slurp those files and make them available on the controller  
to do so.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 21, 2022, 7:32pm UTC](https://forum.ansible.com/t/setting-task-path/36553/3 "2022-04-21T19:32:21Z")

</div>

Another way is to use 'local facts' files  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/setup\_module.html#parameter-fact\_path](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/setup_module.html#parameter-fact_path)

---

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [April 21, 2022, 7:33pm UTC](https://forum.ansible.com/t/setting-task-path/36553/4 "2022-04-21T19:33:02Z")

</div>

Thanks, but where is that set? I dont see it in my yaml file anywhere

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 21, 2022, 7:35pm UTC](https://forum.ansible.com/t/setting-task-path/36553/5 "2022-04-21T19:35:32Z")

</div>

On your task, which you have not shared, I only know it is  
include\_vars due to the return data

normally if you want to get help you should show the task(s) that are  
failing and as much of the -vvv output you can

---

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [April 21, 2022, 7:37pm UTC](https://forum.ansible.com/t/setting-task-path/36553/6 "2022-04-21T19:37:21Z")

</div>

This is full error:

TASK [Include vars of server.yaml file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/roles/azurebuild/tasks/main.yml:4  
Thursday 21 April 2022 14:35:57 -0500 (0:00:00.020) 0:00:00.020 \*\*\*\*\*\*\*\*  
Thursday 21 April 2022 14:35:57 -0500 (0:00:00.019) 0:00:00.019 \*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {  
“ansible\_facts”: {  
“server”: {}  
},  
“ansible\_included\_var\_files”: ,  
“changed”: false,  
“message”: “Could not find or access ‘/etc/ansible/servers/USAEDSADMP01.yaml’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote\_src option”  
}

Below is my ansible.cfg:

[inventory]  
enable\_plugins = yaml, ini

#ansible executes tasks by copying a file onto the remote host, executing it and reporting the results back to the control machine.  
#With pipelining enabled, Ansible can send commands directly to STDIN through a persistent SSH connection, which is much faster than the default process.  
#[ssh\_connection]  
pipelining = True

[defaults]

# some basic default values…

inventory=./hosts  
forks = 10  
#find a task’s time consumption and identify which jobs are slowing down your plays  
callbacks\_enabled = timer, profile\_tasks, profile\_roles  
#facts gathering can be improved using fact caching.  
#It can use redis or create JSON files on your Ansible host. Following options in the ansible.cfg file will use smart gathering and facts caching with a local json file  
gathering = smart  
fact\_caching = jsonfile  
fact\_caching\_connection = /tmp  
strategy\_plugins = /usr/local/lib/python3.8/dist-packages/ansible\_mitogen/plugins/strategy  
strategy = mitogen\_linear

---

<div class="post-metadata">

**Author:** ![Nitrous](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@Nitrous](https://forum.ansible.com/u/Nitrous)\
**Post date:** [April 21, 2022, 7:40pm UTC](https://forum.ansible.com/t/setting-task-path/36553/7 "2022-04-21T19:40:47Z")

</div>

- hosts: localhost  
gather\_facts: no  
tasks:

- name: Include vars of server.yaml file  
include\_vars:  
file: /etc/Ansiblectrl01/servers/{{ hostname }}.yaml  
name: server

- name: Create a network interface with dns servers  
azure\_rm\_networkinterface:  
name: “{{ hostname }}-nic1”  
state: present  
resource\_group: ‘{{ server.az\_vm\_rg }}’  
enable\_accelerated\_networking: no  
virtual\_network:  
name: ‘{{ server.az\_nic\_vnet }}’  
resource\_group: ‘{{ server.az\_vnet\_rg }}’  
subnet\_name: ‘{{ server.az\_nic\_subnet }}’  
public\_ip: false  
dns\_servers:

- ‘{{ server.dnsserver1 }}’

- ‘{{ server.dnsserver2 }}’

- ‘{{ server.dnsserver3 }}’  
ip\_configurations:

- name: lan1  
primary: True  
private\_ip\_allocation\_method: Static  
private\_ip\_address: ‘{{ server.az\_vm\_ipaddress }}’  
application\_security\_groups: ‘{{ server.az\_vm\_asg | default(omit) }}’  
create\_with\_security\_group: false  
#tags: ‘{{ server.az\_vm\_tags }}’  
register: azure\_nic  
#ignore\_errors: yes
