3
votes

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

I can deploy a template directly like this: gcloud deployment-manager deployments create a-single-vm --template vm_template.jinja

But what if that template depends on other files that need to be imported? If using a --config file you can define import in that file and call the template as a resource. But you cant pass parameter/properties to a config file. I want to call a template directly to pass --properties via the command line but that template also needs to import other files.

EDIT: What I needed was a top level jinja template instead of a config. My confusion was that you cant use imports in a jinja template without a schema file- it was failing and I thought it wasnt supported. So the solution was just swap out the config with a jinja template (with schema file) and then I can use --properies

1

1 Answers

2
votes

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

Hope it helps