出于某种原因,Jinja声称它无法找到我在Fabric任务中指定的模板:
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)
但是每次跑步,我都会
jinja2.exceptions.TemplateNotFound: /path/to/dir/conf/httpd.conf
它绝对住在那里。发生了什么事?
答案 0 :(得分:5)
为了澄清oselivanov的答案,这将是你的正确格式的例子:
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)
答案 1 :(得分:2)
来自upload_template docstring:
或者,如果
use_jinja
设置为True并且您有Jinja2 模板库可用,Jinja将用于渲染模板 代替。模板将从调用用户的当前工作中加载 默认情况下为目录,如果已给出,则为template_dir
。
Сonfusingbehavior。
答案 2 :(得分:0)
这实际上可能是一个错误。