Problem/Motivation
Currently install profiles like standard provide optional configuration. When modelling these as recipes, we face the question of how to support such conditionality. For example, various media-related configuration entities will be installed only if/when the media module is installed. To replicate this functionality in a standard recipe, we'll need the ability to install with our without including media and the recipes that require it.
Proposed resolution
One possible approach would be an install mode where all recipes listed under "suggest" are installed. In this approach, a standard recipe would suggest optional recipes. At recipe run time, an optional argument determines whether the suggested packages are also installed. This may require user feedback; see #3303126: Make it possible for recipes to prompt for input values.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork distributions_recipes-3304895
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nedjoComment #3
nedjoComment #4
narendrarI am also facing similar problem where I need to convert a contributed module (https://www.drupal.org/project/acquia_cms_event) functionality as recipe. This module creates an Event content type and related configuration are stored in config/optional folder.
What should be the approach to convert it to a Recipe?
Comment #5
thejimbirch commentedWe are slowly identifying this as a top issue.
Comment #6
thejimbirch commentedComment #7
jurgenhaasI may be wrong with this, but in the context of an installation profile, the
config/optionaldoesn't really make much sense. The installation profile is deterministic as it fully controls what's installed and what not. In other words, the installation profile knows exactly what's available and therefore doesn't actually need the optional configuration. That's different for modules, as they can't tell the context in which they get installed. So, if modules come with optional configuration, that makes sense to me.A recipe, on the other hand, is declarative and describes exactly what it requires and applies that in total to the Drupal site.
Thinking outside the box, do we really require optional configuration with properly structure recipes that depend upon each other?
Comment #8
b_sharpe commentedI would agree with #7. A recipe doesn't have optional config, it's either there or it's not. Module config is not going away nor should required/optional config be converted to a recipe for it (IMO) as the module is saying "Do this always, and if this other thing exist during install, also apply that". A recipe on the other hand could install this same module as well as whatever it requires to get it's optional config to go along with (among other things).
Comment #9
thejimbirch commentedI agree with #7 and #8. Recipes are declarative and should not leave anything to be optional.
The recipe author, to #4's question should decide whether they want the functionality or not, and create their recipes as needed.
I would like to close this issue as Work's as designed, but I feel like we should document how to deal with optional config in modules and installation profiles in the recipe author guide in the docs.
Comment #10
thejimbirch commentedComment #11
johnwebdev commentedHave this been documented?
Comment #12
johnwebdev commentedComment #14
thejimbirch commentedUpdated the Recipe Author Guide.
https://git.drupalcode.org/project/distributions_recipes/-/blob/1.0.x/do...