python - Fabric 和 Jinja 模板上传

标签 python fabric jinja2

出于某种原因,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/

相关文章:

Python Fabric - 未找到主机。请为连接 : 指定(单个)主机字符串

Flask shell - 如何为 url_for _external=True 设置服务器名称?

python - 使用 Flask 将 HTML 文本打印为纯文本

python - 如何在我的 jinja 过滤器中使用 babel 启用时区?

python - 将每个实例蒙版合并回原始图像 Python

python - 从 Django 获取自定义剩余数据

python - 按单词位置选择字符串

python - Python Fabric 中回车符 (\r) 的处理

python Fabric : filter out server output when capturing output of run()

python - 在笔记本中导入 Polars 会导致内核崩溃