Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric and Jinja Template Uploading

For some reason, Jinja claims that it is unable to find a template that I have specified in my Fabric task:

httpd_local = "/path/to/dir/conf/" # with httpd.conf located here
httpd_remote = "/etc/httpd/conf/httpd.conf"

with lcd(httpd_local):
    upload_template(filename='/path/to/dir/conf/httpd.conf', destination=httpd_remote, context=context[hostname], use_jinja=True)

But every time I run, I get

jinja2.exceptions.TemplateNotFound: /path/to/dir/conf/httpd.conf

It definitely lives there though. What's going on?

like image 681
Brian D Avatar asked Aug 03 '11 18:08

Brian D


2 Answers

To clarify oselivanov's answer, this would be your example with the proper format:

httpd_local = "/path/to/dir/conf/" # with httpd.conf located here
httpd_remote = "/etc/httpd/conf/httpd.conf"

with lcd(httpd_local):
    upload_template(filename='httpd.conf', destination=httpd_remote, template_dir='/path/to/dir/conf', context=context[hostname], use_jinja=True)
like image 131
alukach Avatar answered Sep 23 '22 17:09

alukach


From upload_template docstring:

Alternately, if use_jinja is set to True and you have the Jinja2 templating library available, Jinja will be used to render the template instead. Templates will be loaded from the invoking user's current working directory by default, or from template_dir if given.

Сonfusing behavior.

like image 42
oselivanov Avatar answered Sep 24 '22 17:09

oselivanov