Minimize duplication between multiple environments
Description
Gliffy Diagrams
Activity
Stefan Seifert January 10, 2018 at 9:02 PM
using role inheritance works well.
example - this is a role pv-aem-cms-all.yaml
defined in the configuration-management project part:
# Role that combines all application roles and configuration that is common for all environments
inherits:
- role: pv-aem-cms
- role: pv-aem-cms-adaptto
variants:
- variant: aem-author
- variant: aem-publish
config:
crypto:
# URLs of crypto keys to be deployed to AEM (as bundle files)
aesCryptoKeyUrl: ansible-vault:classpath:/crypto/master
hmacCryptoKeyUrl: ansible-vault:classpath:/crypto/hmac
it inherits two roles defines by an AEM applications which contain all osgi configs, application packages etc.
additional the role contains all configuration that is common for all environments.
within the environments only the role pv-aem-cms-all
is references, inhering all files and all common configuration from this role.
Stefan Seifert December 13, 2017 at 5:13 PM
the YAML extension magnolia uses are somewhat "proprietary", and they seem to have implemented their own yaml parser and extensions for it
https://documentation.magnolia-cms.com/display/DOCS56/YAML+inherit+and+include
i'm not sure if we should go this way and extend our YAML processing like this.
a better approach i my opinion is:
create custom CONGA roles for your project hat inherit from the generic roles of AEM definitions (e.g. aem-cms, aem-dispatcher)
define all configuration that is project-specific but common for all stages/environments in the custom role
include these custom roles in the environments - now you should have not duplication in the environment because all shared config resided in the role definition
the role inheritance feature was introduced in CONGA 1.4.0 (https://wcm-io.atlassian.net/browse/WDCONGA-2#icft=WDCONGA-2).
Martin Wehner November 22, 2017 at 5:45 PMEdited
For reference, here is the documentation of how Magnolia is handling the problem within their YAML definitions:
https://documentation.magnolia-cms.com/display/DOCS56/Reusing+configuration
Stefan Seifert November 14, 2017 at 4:12 PM
the YAML file format does not have any support for include/import statements, see also https://stackoverflow.com/q/528281
some YAML libaries add support for a syntax like !include xyz.yaml
- but this is a proprietary extension. other products express custom import statements as part of their YAML grammar. not sure which way we should take
@Martin Wehner can you share some use cases you see for this? do we need it only for the "global" section in the environment files, or for other places as well?
in CONGA you have usually multiple environments - e.g. for different stages test, integration, prod etc.
if you have have a lot of global or role-global parameters they need to be duplicated across the environments. it would be nice to share the common parts between the environment.
we have to check whether we can do this e.g. with includes in the YAML file format, or with a special support in CONGA itself.