coreos / butane

Butane translates human-readable Butane Configs into machine-readable Ignition Configs.
https://coreos.github.io/butane/
Apache License 2.0
255 stars 70 forks source link

Append a text with inline after a specific text via regex #410

Closed rfakit closed 1 year ago

rfakit commented 1 year ago

Hi Is there any way to rehearse the file fcct config to append a text after specific line ? let say we have a text like this

file.txt

line1
line2
specifc line
line3

and with the bellow config

    - path: /root/file.txt
      # 420 (decimal) == 644 (octal)
      mode: 420
      user:
        name: root
      group:
        name: root
      append:
        - inline: |
            some text
      after: SPECIFIC LINE

so the out put file would like bellow

line1
line2
specifc line
some text
line3
bgilbert commented 1 year ago

There isn't, and I don't think we'd want to add one. Configs that used that feature would be too likely to break if newer versions of the OS changed the original file.

If you need something like this, you can write a systemd unit which uses sed to modify the file on first boot (with ConditionFirstBoot=true).