coreos / ignition

First boot installer and configuration tool
https://coreos.github.io/ignition/
Apache License 2.0
814 stars 243 forks source link

RFE: systemd units able to specify contents:source:data like files section #884

Open dustymabe opened 4 years ago

dustymabe commented 4 years ago

Feature Request

With the files section we have:

* **_contents_** (object): options related to the contents of the file.
    * **_compression_** (string): the type of compression used on the contents (null or gzip). Compression cannot be used with S3.
    * **_source_** (string): the URL of the file contents. Supported schemes are `http`, `https`, `tftp`, `s3`, and [`data`][rfc2397].

But with the systemd unit section we only have:

* **_contents_** (string): the contents of the unit.

This means that I can't use a single way to define file contents for files vs systemd units. I end up with doing something like:

#!/bin/bash
SCRIPT_CONTENTS=$(base64 --wrap 0 public-ipv4.sh)
SYSTEMD_UNIT_CONTENTS=$(sed 's|$|\\\\n|g' < issuegen-public-ipv4.service | tr -d '\n')
sed -e "s|SYSTEMD_UNIT_CONTENTS|${SYSTEMD_UNIT_CONTENTS}|" \
    -e "s|SCRIPT_CONTENTS|${SCRIPT_CONTENTS}|" < config.ign.in > config.ign

where in one case I can use base64 and the other I have to replace newlines with \n.

ajeddeloh commented 4 years ago

:+1: I agree. While we're at it we ought to make ignition.config.{merge,replace} work the same way too. This could go into the 3.1.0 spec.

hynd commented 4 years ago

This would be super useful for pulling unit definitions from a remote source too. What are the chances it could make it into v3_2_experimental (and FCC)?

darkmuggle commented 4 years ago

I'd be interested in picking this up.

bgilbert commented 4 years ago

@darkmuggle See https://github.com/coreos/ignition/pull/986.

darkmuggle commented 4 years ago

Indeed @arithx has it. Nevermind, then.

arithx commented 4 years ago

@darkmuggle that PR itself still needs some love (needs to update the translation code & probably fix unit tests). I initially threw it up as-is to open a discussion on whether or not the trade off of losing validation was worth the gain.

If you want to take it from it's current state and drive it to completion I'd be more than happy to cede it over.