quattor / configuration-modules-core

Node Configuration Manager Components for Everyone
www.quattor.org
Other
6 stars 54 forks source link

ncm-dirperm: support for deleting a file/dir #1680

Open aka7 opened 4 months ago

aka7 commented 4 months ago

not sure if any component provide this, but I would like to control deletion of a file using ncm. so if a give path exists in the system it should remove it.

So, it would be neat if ncm-dirperm can provide this support, so have a option in the line of

ensure: string = "present" with match (SELF, '^(absent|present)$')

if set to absent, it should remove the file if it exists. if directory, then remove dir recursively?

ned21 commented 4 months ago

I think you could extend the existing type field (which presently accepts f or d) to also have an 'a' option standing for 'absent'. Unfortunately some of the other fields, e.g. owner and perms, are mandatory and would be confusing in this context.

There are a number of issues with dirperm/symlink such as the handling of duplicates (last one added to list wins) and more crucially, what happens if you add a file /foo/bar/baz and then later add an entry for /foo, as well as potential conflicts between dirperm and symlink. There was an idea to merge both of these into a new component, ncm-path, that would handle these by processing all paths in a shortest to longest order, erroring on duplicates and could then also be extended to handle file absence. Unfortunately I don't think we even got as far as agreeing a schema that cover so many use cases! :(

jrha commented 4 months ago

We have discussed having "this path must not exist" functionality before, I'm very much for it. Ideally it would in the new ncm-path, but pragmatically it could be added to dirperm with all the above caveats @ned21 highlighted.