Inventory location inconsistency #130

Closed
opened 2021-11-20 13:24:25 +00:00 by ungleich-gitea · 12 comments

Created by: matthijskooijman

I've been looking at the inventory feature, and was a bit surprised about a few things:

  • The inventory location defaults to ~/.cdist/inventory, whereas everything else seems to default to the in-distribution location (e.g cdist/conf/manifest/init). Is there any compelling for this reason?
  • An in-distibution location is used when $HOME is unset, but not when it is empty. This prevents switching to the other behaviour using HOME= ./bin/cdist ..., which isn't terribly convenient.
  • The in-distribution location used (when $HOME is unset) seems inconsistent: it is cdist/inventory, where I would expect cdist/conf/inventory, along with the rest of the config.
*Created by: matthijskooijman* I've been looking at the inventory feature, and was a bit surprised about a few things: - The inventory location defaults to `~/.cdist/inventory`, whereas everything else seems to default to the in-distribution location (e.g `cdist/conf/manifest/init`). Is there any compelling for this reason? - An in-distibution location is used when `$HOME` is unset, but not when it is empty. This prevents switching to the other behaviour using `HOME= ./bin/cdist ...`, which isn't terribly convenient. - The in-distribution location used (when `$HOME` is unset) seems inconsistent: it is `cdist/inventory`, where I would expect `cdist/conf/inventory`, along with the rest of the config.
Author
Owner

Created by: matthijskooijman

A bit late, but: Thanks! Works like a charm for me :-)

*Created by: matthijskooijman* A bit late, but: Thanks! Works like a charm for me :-)
Author
Owner

Created by: darko-poljak

@matthijskooijman @telmich I think we can take in-distribution config file into account if it exists.

*Created by: darko-poljak* @matthijskooijman @telmich I think we can take in-distribution config file into account if it exists.
Author
Owner

Created by: darko-poljak

@telmich Your thoughts?

*Created by: darko-poljak* @telmich Your thoughts?
Author
Owner

Created by: matthijskooijman

That would work, except that:

  • This requires users to modify their environment after cloning the repo (with the risk of users forgetting to make the link, or later forgetting they have the link and be surprised things are not behaving as expected, etc.)
  • This modifies the config for all cdist setups a user might have
*Created by: matthijskooijman* That would work, except that: - This requires users to modify their environment after cloning the repo (with the risk of users forgetting to make the link, or later forgetting they have the link and be surprised things are not behaving as expected, etc.) - This modifies the config for *all* cdist setups a user might have
Author
Owner

Created by: darko-poljak

How about ln -s <file inside repo> ~/.cdist.cfg ?

*Created by: darko-poljak* How about `ln -s <file inside repo> ~/.cdist.cfg` ?
Author
Owner

Created by: matthijskooijman

Yeah, but none of these are inside my repository, so I can't make the repository self-contained (and it also won't work if I want to work with multiple self-contained repositories). Perhaps I'm thinking about this in the wrong way, but a in-distribution (default) config that is parsed would make sense, right?

*Created by: matthijskooijman* Yeah, but none of these are inside my repository, so I can't make the repository self-contained (and it also won't work if I want to work with multiple self-contained repositories). Perhaps I'm thinking about this in the wrong way, but a in-distribution (default) config that is parsed would make sense, right?
Author
Owner

Created by: darko-poljak

@matthijskooijman You can have user's configuration file (first one found of ~/.cdist.cfg, $XDG_CONFIG_HOME/cdist/cdist.cfg, in specified order) or
system-wide configuration file (/etc/cdist.cfg).

*Created by: darko-poljak* @matthijskooijman You can have user's configuration file (first one found of ~/.cdist.cfg, $XDG_CONFIG_HOME/cdist/cdist.cfg, in specified order) or system-wide configuration file (/etc/cdist.cfg).
Author
Owner

Created by: matthijskooijman

Yeah, that's also an option. I still need to pass a -g option explicitly. Would it make sense to automatically load a config file from the distribution, if it exists? e.g. cdist/conf/cdist.conf or something?

*Created by: matthijskooijman* Yeah, that's also an option. I still need to pass a -g option explicitly. Would it make sense to automatically load a config file from the distribution, if it exists? e.g. `cdist/conf/cdist.conf` or something?
Author
Owner

Created by: darko-poljak

@matthijskooijman You can also use configuration file: https://www.nico.schottelius.org/software/cdist/man/latest/cdist-configuration.html
There is an option for inventory_dir. If you want a config file in git repo you can also have your home dir config file be link to the one in git repo.
Does this fit your needs?

*Created by: darko-poljak* @matthijskooijman You can also use configuration file: https://www.nico.schottelius.org/software/cdist/man/latest/cdist-configuration.html There is an option for inventory_dir. If you want a config file in git repo you can also have your home dir config file be link to the one in git repo. Does this fit your needs?
Author
Owner

Created by: matthijskooijman

Works, thanks.

As for the in-distribution location, let me explain my usecase. I'm using cdist to configure a number of similar machines. For this, I forked the cdist repo, as recommended, and put all the needed configuration in there. To make this repo a fully self-contained tool to easily configure and change all these machines, it should include a list of these machines, so any changes made can be easily pushed to all of them.

Currently, I should either:

  • Distribute the list of machines out-of-band,
  • or pass en explicit -I option whenever calling cdist.

Neither of which seem very elegant to me.

Also, I would think the inventory is more configuration (in cdist/conf) than code (which is the rest of cdist).

However, having the inventory as something in addition to the configuration could also make sense. I find the current location (inside the python package) a bit weird, but thinking about it, I actually think the same applies to the cdist/conf directory...

*Created by: matthijskooijman* Works, thanks. As for the in-distribution location, let me explain my usecase. I'm using cdist to configure a number of similar machines. For this, I forked the cdist repo, as recommended, and put all the needed configuration in there. To make this repo a fully self-contained tool to easily configure and change all these machines, it should include a list of these machines, so any changes made can be easily pushed to all of them. Currently, I should either: - Distribute the list of machines out-of-band, - or pass en explicit -I option whenever calling cdist. Neither of which seem very elegant to me. Also, I would think the inventory is more configuration (in `cdist/conf`) than code (which is the rest of `cdist`). However, having the inventory as something *in addition to* the configuration could also make sense. I find the current location (inside the python package) a bit weird, but thinking about it, I actually think the same applies to the `cdist/conf` directory...
Author
Owner

Created by: darko-poljak

@matthijskooijman Can you test the following commit, related to empty HOME env var? 2b5f1a0148

*Created by: darko-poljak* @matthijskooijman Can you test the following commit, related to empty HOME env var? https://github.com/ungleich/cdist/commit/2b5f1a01480a3e5ff4af0dc307387299a64db3a4
Author
Owner

Created by: darko-poljak

@matthijskooijman Inventory location defaults to ~/.cdist/inventory because there is nothing related to inventory that comes with distribution, except implementation support. Also, in-distribution location cdist/inventory is used instead of cdist/conf/inventory because inventory is not tight coupled with manifests and types that are used for configuring hosts, and this is what is held in conf directory.
The HOME env var empty case will be fixed.

*Created by: darko-poljak* @matthijskooijman Inventory location defaults to ~/.cdist/inventory because there is nothing related to inventory that comes with distribution, except implementation support. Also, in-distribution location cdist/inventory is used instead of cdist/conf/inventory because inventory is not tight coupled with manifests and types that are used for configuring hosts, and this is what is held in conf directory. The HOME env var empty case will be fixed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#130
No description provided.