include_vars not working correctly in case of remote hosts

1,540 views
Skip to first unread message

vikram patil

unread,
Oct 28, 2014, 1:40:09 AM10/28/14
to ansible...@googlegroups.com
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.


  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


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







Sankalp Khare

unread,
Oct 29, 2014, 2:48:54 PM10/29/14
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Oct 30, 2014, 4:38:29 PM10/30/14
to ansible...@googlegroups.com
include_vars always runs on your local machine, this is what it does :)



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/317426fe-72da-42eb-80ea-2fdb19e1641c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages