出于某种原因,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
不过它肯定住在那里。怎么回事?
最佳答案
为了澄清 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)
关于python - Fabric 和 Jinja 模板上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6931375/