Delegate with template with source file on remote

20 views
Skip to first unread message

Mehdi B

unread,
Dec 29, 2016, 5:47:06 AM12/29/16
to Ansible Project
Hi,

I have a project where I wanted to use templates but instead of having them on ansible server, I wanted to use a remote file and deploy it.

Why? As I'm cloning site project on remote front servers, and the template is in the project so dev's could update it. 

So I have server 1 ( ansible controller )

Server 2 ( target ) with template.php.dist file on /home

I created a role with main task:


  - name: Create conf config/template.php
    template: >
         src="/home/template.php.dist"
         dest="/home/licom.php"
    delegate_to: "{{ item }}"
    with_items:
         - "{{ inventory_hostname }}"

So I delegate the task to execute on server 2 here but seem that the template will always check for server 1 as source. Is there a way to changer the source server? So I won't need to clone the entire project on server 1?

Thanks
Mehdi B

Mehdi B

unread,
Dec 29, 2016, 5:52:58 AM12/29/16
to Ansible Project
After checking the archive:

Seem the point here as we need jinja2 on remote server too and python. So best is festching it once using 


Then pushing back the file.

If anyone have better idea you are welcome.

Mehdi B
Reply all
Reply to author
Forward
0 new messages