-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically create storage config from source directory #295
Comments
Have you tried the |
To be honest, I wasn't aware that this exists 😲 However, checking it out now it definitely seems to make a few things easier, especially including file contents, but it doesn't really solve the issue. The only line omitted with Now knowing that Files owned by root aren't really an issue for me. It's other user's files, because we heavily use rootless containers. |
We kept the initial
And we could have |
Yeah, this sounds very good 👍 This way I could have a Conflicts with multiple patterns matching was no big deal for my Python implementation by the way, the rules simply stack (just a fyi, I'm totally file with the solution above). #118 actually was a bigger deal considering conflicts, as all rootless containers require adding their users to By the way: I've just released said Python script. It's called |
Hi there, I usually avoid writing comments that are basically a "+1" but as this issue hasn't seen any activity recently, I hope it's fine to point out that I would love to have more options for |
This is exactly what we need for rootless containers:
We currently have to specify each single file and directory if we want them to be owned by an user. @bgilbert any chance this will be implemented ? |
I know it's a little clumsy, but till (if ever) this is implemented, you might want to take a look at https://github.com/PhrozenByte/mbutane. It implements just this using a Python wrapper around Butane. It surely is no perfect solution and any native solution would be way superior, but it works and makes my life easier for a few years now. |
I think we would rather need to have this natively in the main butane project TBH |
/kind enhancement
I'm using Butane to provision some servers with rather complex setups and unfortunately I've to say that Butane's way of handling files, directories and links makes things quite hard right now.
Adding new files, directories and links to a server is probably the most common task when provisioning a server, however, right now one has to add every single file manually to
config.bu
. The biggest problem are files, as one has to either inline their contents (making the config unreadable pretty fast), or one has to create the source file separately and set a source path inconfig.bu
. Luckily one doesn't have to add full directory trees toconfig.bu
, because Ignition will silently create missing directories anyway - unless we want the directories not to be owned by root. Then we must add the full directory tree, too.Here's an example of such a
config.bu
- that needs to be multiplied a few times, once per rootless container (you don't have to actually check the config, it doesn't matter, it's just an example).This is very repetitive and error-prone (did you see the typo for
/srv/containers/acme/.config/systemd/user
?).Thus I'd like to suggest to add a new feature allowing Butane to automatically create storage configs from a source directory. For this we need two additional command line options,
--storage-src-dir
and--storage-config-file
(or similar).--storage-src-dir
takes a path to a directory,--storage-config-file
a file name (defaults tosubconfig.bu
, or similar).Butane iterates all files, directories and links in
--storage-src-dir
and automatically creates entries for these files in the resulting Ignition config, addingpath
,contents
(for files only) andtarget
(for links only) respectively. File ownership and permissions are ignored. This allows users to add files to their Ignition config by simply creating the necessary files and directories in the--storage-src-dir
directory. For all other parameters (likeuser
,group
,mode
andoverwrite
), of a directory, file or link, one uses magic files likesubconfig.bu
, matching the--storage-config-file
command line option.Here's an example of a
subconfig.bu
stored at…/srv/containers/acme/subconfig.bu
The
config.bu
is now way simpler.subconfig.bu
files are used to merge their config into the specification of files, directories and links matching thepath
pattern below this point. Thepath
patterns are just usualglob
patterns, like e.g. in.gitignore
files. So, for example, thepath: /
directory config addsmode: 0700
to the specification of/srv/containers/acme
. Since the directory patternpath: "*"
matches everything, it ensures that all directories below/srv/containers/acme
(including/srv/containers/acme
) are owned byacme
. The same for files and links, which additionally setoverwrite: true
.I wrote a pre-processor for Butane with Python (unfortunately I don't know Go...) that implements exactly this (it also implements #118; no public release yet). It makes things way easier. What do you guys think about this?
The text was updated successfully, but these errors were encountered: