# include\_vars not working correctly in case of remote hosts

**URL:** <https://forum.ansible.com/t/include-vars-not-working-correctly-in-case-of-remote-hosts/16622>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [October 28, 2014, 5:40am UTC](https://forum.ansible.com/t/include-vars-not-working-correctly-in-case-of-remote-hosts/16622 "2014-10-28T05:40:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikram\_patil](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@vikram\_patil](https://forum.ansible.com/u/vikram_patil)\
**Post date:** [October 28, 2014, 5:40am UTC](https://forum.ansible.com/t/include-vars-not-working-correctly-in-case-of-remote-hosts/16622/1 "2014-10-28T05:40:09Z")

</div>

Hello All,

I am trying to setup ansible script which fetches config file from S3 and stores on remote node in home directory for User. In next task I would like to include\_vars from this file but somehow include\_vars fails to find file on remote machine as it always looks in  
my local machine.

- hosts: [XYZcompute.amazonaws.com](http://XYZcompute.amazonaws.com)  
connection: ssh  
remote\_user: ubuntu  
gather\_facts: False  
vars:  
remote\_env:  
…  
roles:

- python

- uwsgi  
tasks:

- shell: echo $HOME  
register: USER\_HOME  
ignore\_errors: True

- name: Access file from s3

s3: bucket=MYBUCKET object={{CONFIGURATION\_ENV}}.yml dest=~/{{CONFIGURATION\_ENV}}.yml mode=get force=true  
environment: remote\_env

- name: “Loading vars”

include\_vars: ‘~/{{CONFIGURATION\_ENV}}.yml’  
delegate\_to: [XYZ.compute.amazonaws.com](http://XYZ.compute.amazonaws.com)

lets say I am invoking above playbook from user vikram include\_vars fails saying

file could not read: /home/vikram/production.yml

but I want ansible to load variables from /home/ubuntu/production.yml

-Vikram

---

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [October 29, 2014, 6:48pm UTC](https://forum.ansible.com/t/include-vars-not-working-correctly-in-case-of-remote-hosts/16622/2 "2014-10-29T18:48:54Z")

</div>

The end-goal is to get the variables loaded into your ansible run. How about separating out your task into two distinct activities:

1. Fetching the file from S3 _on the machine where you are doing the ansible run_, and loading variables from it
2. Uploading a copy of the file to the remote host’s home directory as well (if that is part of your requirements)  
Just my two cents.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 30, 2014, 8:38pm UTC](https://forum.ansible.com/t/include-vars-not-working-correctly-in-case-of-remote-hosts/16622/3 "2014-10-30T20:38:26Z")

</div>

include\_vars always runs on your local machine, this is what it does 🙂
