Support for sub-types #106

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

Created by: sideeffect42

When writing cdist types I very often have the problem that I would need multiple possible "entry-points" in a single type.

What's the situation?

Say I want to implement a type to install and configure an Apache web server.
There are multiple pieces needed to configure Apache.
(For ease of getting my point across I'm assuming a Debian-based system here.)

  1. I need to install the package.
  2. I probably want to enable certain mods.
  3. I probably want to create one/some vhost(s).
  4. I might want to fine tune some settings of the web server.

What's the solution (now)?
As it is now, I would need to create at least 4 different types (for each of the steps described above), like __apache2_install, __apache2_mod, __apache2_vhost, __apache2_conf

And what exactly is the problem now?
Creating four types makes the types very hard to distribute. Of course I could try to get all of these types upstream, but that doesn't work for all of the million of possible types.

I used to put each type in a separate Git repository and then submodule those into the type/ folder of my ~/.cdist repository.

What I envisage as a better solution
It would be great if the type lookup of cdist could be extended to look two levels deep, so that I could bundle up all of the four types into one Git repository.

Resulting in a directory structure similar to this:

type
└── __apache2
    ├── _conf
    │   ├── man.rst
    │   ├── manifest
    │   └── parameter
    ├── _install
    │   ├── man.rst
    │   ├── manifest
    │   ├── parameter
    │   └── singleton
    ├── _mod
    │   ├── man.rst
    │   ├── manifest
    │   └── parameter
    └── _vhost
        ├── man.rst
        ├── manifest
        └── parameter
...
*Created by: sideeffect42* When writing cdist types I very often have the problem that I would need multiple possible "entry-points" in a single type. **What's the situation?** Say I want to implement a type to install and configure an Apache web server. There are multiple pieces needed to configure Apache. (For ease of getting my point across I'm assuming a Debian-based system here.) 1. I need to install the package. 2. I probably want to enable certain mods. 3. I probably want to create one/some vhost(s). 4. I might want to fine tune some settings of the web server. **What's the solution (now)?** As it is now, I would need to create at least 4 different types (for each of the steps described above), like `__apache2_install`, `__apache2_mod`, `__apache2_vhost`, `__apache2_conf` **And what exactly is the problem now?** Creating four types makes the types very hard to distribute. Of course I could try to get all of these types upstream, but that doesn't work for all of the million of possible types. I used to put each type in a separate Git repository and then submodule those into the `type/` folder of my `~/.cdist` repository. **What I envisage as a better solution** It would be great if the type lookup of cdist could be extended to look two levels deep, so that I could bundle up all of the four types into one Git repository. Resulting in a directory structure similar to this: ``` type └── __apache2 ├── _conf │   ├── man.rst │   ├── manifest │   └── parameter ├── _install │   ├── man.rst │   ├── manifest │   ├── parameter │   └── singleton ├── _mod │   ├── man.rst │   ├── manifest │   └── parameter └── _vhost ├── man.rst ├── manifest └── parameter ... ```
ungleich-gitea added the
Stale
label 2021-11-20 13:24:00 +00:00
Author
Owner

mentioned in issue #854

mentioned in issue #854
Author
Owner

mentioned in issue #804

mentioned in issue #804
Author
Owner

closed

closed
Author
Owner

Created by: sideeffect42

@darko-poljak: Thanks for the hint. I missed that option.
Using CDIST_PATH should work, but it requires me to manually set the environment variable manually each time I want to run cdist (or write a script for it).

Would it be possible to have cdist to automatically "prepopulate" (read: concat with the passed environment variable) the CDIST_PATH using something like find $CDIST_REPO/packages -type d -maxdepth 1?
This way there would be a convenient method to install bundles/packages/modules of types.

*Created by: sideeffect42* @darko-poljak: Thanks for the hint. I missed that option. Using CDIST_PATH should work, but it requires me to manually set the environment variable manually each time I want to run cdist (or write a script for it). Would it be possible to have cdist to automatically "prepopulate" (read: concat with the passed environment variable) the CDIST_PATH using something like `find $CDIST_REPO/packages -type d -maxdepth 1`? This way there would be a convenient method to install bundles/packages/modules of types.
Author
Owner

Created by: darko-poljak

@sideeffect42 Would CDIST_PATH (https://www.nico.schottelius.org/software/cdist/man/latest/cdist-reference.html#environment-variables-for-writing) help? You can have separate type repos and all used by cdist by defining CDIST_PATH.

*Created by: darko-poljak* @sideeffect42 Would CDIST_PATH (https://www.nico.schottelius.org/software/cdist/man/latest/cdist-reference.html#environment-variables-for-writing) help? You can have separate type repos and all used by cdist by defining CDIST_PATH.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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#106
No description provided.