google 部署管理器,你可以导入直接用--template 调用的jinja 模板中的文件吗?

google deployment manager, can you import files in jinja template that you call directly with --template?

https://cloud.google.com/deployment-manager/docs/configuration/templates/create-basic-template

我可以这样直接部署一个模板:gcloud deployment-manager deployments create a-single-vm --template vm_template.jinja

但是如果该模板依赖于需要导入的其他文件怎么办?如果使用 --config 文件,您可以在该文件中定义导入并将模板作为资源调用。但是您不能将 parameter/properties 传递给配置文件。我想直接调用模板通过命令行传递--properties但是那个模板还需要导入其他文件

编辑:我需要的是顶级神社模板而不是配置。我的困惑是你不能在没有模式文件的情况下在 jinja 模板中使用导入——它失败了,我认为它不受支持。所以解决方案只是用 jinja 模板(带有模式文件)交换配置,然后我可以使用 --properies

Maybe you can try importing the dependent files into your config file as follows:

imports:
- path: vm-template.jinja
- path: vm-template-2.jinja

# In the resources section below, the properties of the resources are replaced
# with the names of the templates.

resources:
- name: vm-1
  type: vm-template.jinja
- name: vm-2
  type: vm-template-2.jinja

and Set Arbitrary Metadata insito create a special variable that you can pass and might use in other applications outside of Deployment Manager:

properties:
  size:
    type: integer
    default: 2
    description: Number of Mongo Slaves
    variable-x: ultra-secret-sauce
  • More info about gcloud deployment-manager deployments create optional flags and example can be found here.
  • More info about passing properties using a Schema can be found here

希望对您有所帮助