Project

General

Profile

Actions

Feature #15320

open

Make it possible to get an arbitrary templated script from foreman during provisioning

Added by Jan Schermer almost 8 years ago. Updated almost 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Templates
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Preseed has its limits, particularly on line lengths so inlining more complex scripts is impossible.
In order to do more complicated stuff, one has to do something like:
d-i preseed/late_command string wget http://192.168.0.1:8000/provision.sh -O /target/root/provision.sh ; sh /target/root/provision.sh

It would be nice to be able to get an arbitrary template/script like this:

wget <%= foreman_url('arbitraryscript') >
wget <
= foreman_url('someother_arbitraryscript') %>

Right now it's possible to do that for one "script", which is not enough and one has to do hacks using parameters when executing the script in different phases of the provisioning.

One could also use this for configuration creation by having foreman interpret an ERB template, possibly even outside of provisioning...

Thank you.

Actions #1

Updated by Dominic Cleal almost 8 years ago

  • Category set to Templates
Actions #2

Updated by Marek Hulán almost 8 years ago

You might be interested in remote execution plugin - https://www.theforeman.org/plugins/foreman_remote_execution/0.3/index.html
The only missing piece is that we currently can't automate running a job just after provisioning. It could be triggered by API though. I believe job templates previewing would be even generic enough for using it just as a templating mechanism.

Actions #3

Updated by Jan Schermer almost 8 years ago

Marek Hulán wrote:

You might be interested in remote execution plugin - https://www.theforeman.org/plugins/foreman_remote_execution/0.3/index.html
The only missing piece is that we currently can't automate running a job just after provisioning. It could be triggered by API though. I believe job templates previewing would be even generic enough for using it just as a templating mechanism.

That would work, but is much more complicated (and you have to cleanup afterwards unless you want foreman to have access to the host). I feel it would be much easier to simply extend the provisioning templates for this so I could wget a template (and everything is almost already in place, isn't it?). Also, I want the script to execute in the installer context - not in /target for example (or maybe combination of both).
But you are right, after first reboot, it's better to use remote execution plugin (unless you have puppet for example). During provisioning, not so much, IMO.

Actions #4

Updated by Marek Hulán almost 8 years ago

Correct. We'd have to need rendering template with a given name for a host (we already do this in UI for previewing). We might not even need extra template type if we allow snippets to be rendered.

Actions #5

Updated by Jan Schermer almost 8 years ago

Marek Hulán wrote:

Correct. We'd have to need rendering template with a given name for a host (we already do this in UI for previewing). We might not even need extra template type if we allow snippets to be rendered.

Exactly. It should be a different type, though, so secrets can't leak by requesting arbitrary snippet. Current type "script" could be fine? Or are tokens sufficient?
Something like: <%= foreman_url('scripts/scriptname')

I'm not sure whether this is something like Hostgroup-Based rendering mentioned in the manual (/unattended/template/Template Name/Hostgroup Name), I failed to get that to work.

Actions #6

Updated by Marek Hulán almost 8 years ago

I think the token should be enough. Hostgroup templates work differently I think.

Actions

Also available in: Atom PDF