no way to generate filenames from templates

Bug #1258351 reported by Steve Baker on 2013-12-06
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

For example, the following template would generate a different file for each entry in confs:

^--- first line has output paths--^
Content goes here {{reference variables}}
Add lines

This would be useful for heat software config, where a server's metadata contains a list of actionable data, one for each software deployment resource associated with that server.

Changed in os-apply-config:
status: New → Triaged
importance: Undecided → Wishlist

Fix proposed to branch: master

Changed in os-apply-config:
assignee: nobody → JunJie Nan (nanjj)
status: Triaged → In Progress

Hi, this is an interesting proposal. But I think the approach is overly limiting if we're going to allow dynamic file name specification.

The first line of a template isn't special today, and making it special will be super surprising.

This needs some design work: specifically we need to make sure this doesn't conflict with the simple case of file in -> file out, while still solving your problem (that I don't quite follow).

The pattern you've expressed is a little concerning for me because bad data could write a custom root ssh key to /root/.ssh/passwords, for instance.

So - lets gather your requirements, come up with a secure, robust design, and then this can move forward.

Clint Byrum (clint-fewbar) wrote :

Robert, I actually did discuss this at length with Steve Baker, but I never fully expressed my intention here and had actually intended to do a bit more documentation of it before implementation was started.

The things that are missing:

* These are path-templates, and would be treated differently than regular templates. The first line would not be special in normal templates. Where to store them was something I hadn't decided on yet.
* The first line is a single pattern, not TARGETS=
* The referenced variables themselves must not have slashes. We won't allow substitution of hierarchy. The template author controls where you can write these still, but gives up the contents of the directory to the metadata.
* The whole template would need to be rendered with the block context from the path _and_ the rest of the metadata, which may be tricky unless pystache lets us pass in an active context.
* The use case for this is to be able to write things into a .d type directory structure. So given metadata like this:

    - hostname:
      port: 80
      document_root: /srv/
    - hostname:
      port: 8000
      document_root: /srv/

Your path-controlled template would be

<VirtualHost *:{{port}}>
  DocumentRoot {{document_root}}
  ServerName {{hostname}}

Steve Baker had another use case for it that made sense.

Steve Baker (steve-stevebaker) wrote :

I don't think my use case is valid any more, but here it is for posterity.

Polled metadata contains a list of configuration scripts. Using this mechanism each script could be written out as os-refresh-config scripts which get run during post-configure.

This has some issues however:
* os-apply-config executes executable scripts straight after it generates them
* each script needs to be invoked with its own set of inputs, which implies writing out a wrapper script with loads the inputs then executes the actual script

My current approach is to write out all of the metadata required to a json conf file, and just have a static python os-refresh-config script which loads the config, writes out scripts, and invokes them with the appropriate environment, and signals the result.

Changed in os-apply-config:
assignee: JunJie Nan (nanjj) → nobody
status: In Progress → Triaged
summary: - Allow meta templates which can generate moustache-derived filenames
+ no way to generate filenames from templates
Alexis Lee (alexisl) wrote :

Ideally we'd be able to add extra files into the conf.d directory of an already running instance by simply stack-updating a section like this into the metadata:

      - body: "lorem ipsum dolores {{}}"
        path: "/etc/maud/conf.d/xyzzy"

This would be a simple extension to the os-apply-config os-refresh-config script.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers