Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to include other files into a jobspec #260

Closed
cconstantine opened this issue Dec 14, 2018 · 1 comment
Closed

Add ability to include other files into a jobspec #260

cconstantine opened this issue Dec 14, 2018 · 1 comment

Comments

@cconstantine
Copy link

This is a feature request for a method for including other files into a jobspec.

I would like to deploy a number of services into a single job, and each one requires a static configuration file to run. I could use heredocs with a template stanza to configure them, but that means putting ALL of the configuration files contents into a single file.

In addition to allowing me to put service configuration files into multiple files, it would generally allow people to split up large or complicated job specs into multiple pieces, and re-use repeated portions of a jobspec.

Example Nomad Job Template
This is an example interface for including files. I have no attachment to the specific method names or formats for how this would work, but this would satisfy me.

variables.yml:

---
configurationVariables:
  variable: someValue

job.tpl:

job "foo" {
  ...
  group "someGroup" {
    task "someTask" {
      template {
        data = <<EOF
[[ include "configuration.yml.tpl" .configurationVariables ]]
EOF
        destination = "configuration.yml"
      }
    }
  }
}

configuration.yml.tpl:

---
some: rather
large: configuration
file: [[ .variable ]]

Output of running levant render with the above files:

job "foo" {
  ...
  group "someGroup" {
    task "someTask" {
      template {
        data = <<EOF
---
some: rather
large: configuration
file: someValue
EOF
        destination = "configuration.yml"
      }
    }
  }
}
@jrasell
Copy link
Member

jrasell commented Dec 17, 2018

Thanks for the request @cconstantine. The ability to have a template function which attempts to read the file and then add the contents to the section should be doable. Having those contents contain a variable required for substitution will be interesting, that depends heavy on the order of the template rendering which I will attempt to test when working on this for you.

jrasell added a commit that referenced this issue Dec 18, 2018
Add fileContents template func to read a file into a template.
@jrasell jrasell closed this as completed Nov 27, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants