Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple path in environmentpath parameter #708

Closed
achevalet opened this issue Oct 9, 2019 · 10 comments · Fixed by #803
Closed

Support multiple path in environmentpath parameter #708

achevalet opened this issue Oct 9, 2019 · 10 comments · Fixed by #803

Comments

@achevalet
Copy link

Currently only one path is accepted. puppet.conf is correctly updated but it fails on folder creation. We probably need a loop at https://github.com/theforeman/puppet-puppet/blob/master/manifests/server/config.pp#L225

ref: https://puppet.com/docs/puppet/6.4/environments_creating.html#environmentpath

@ekohl
Copy link
Member

ekohl commented Oct 9, 2019

We can split it on : but if there's a variable in there (which is valid for Puppet), it will be an issue. Probably good to special case that and make the user responsible for it. Could you come up with a patch for this?

@achevalet
Copy link
Author

Yes I can provide a patch, just need to agree on the implementation. Variables are currently not supported in there so it will not change current behaviour, right? The problem I can see is with $envs_target parameter where a 1:1 matching with $envs_dir might be confusing.
Perhaps we could add a new flag like $create_envs_dir which would skip folder creation if set to false and make the user responsible for it, and allow only one path in $envs_dir when $envs_target is specified. What do you think?

@achevalet
Copy link
Author

Actually there are other references to $envs_dir or $server_envs_dir:

manifests/params.pp:248:  $server_common_modules_path  = unique(["${server_envs_dir}/common", "${codedir}/modules", "${sharedir}/modules", '/usr/share/puppet/modules'])
manifests/server.pp:463:      $config_version_cmd = "git --git-dir ${envs_dir}/\$environment/.git describe --all --long"
manifests/server/config.pp:253:      require => File[$::puppet::vardir, $::puppet::server::envs_dir],
templates/server/post-receive.erb:13:ENVIRONMENT_BASEDIR = "<%= scope.lookupvar("puppet::server::envs_dir") %>"

which makes it not so easy to support multiple values with a single parameter..

@cabrinha
Copy link
Contributor

To add on to this, I'm currently having an issue where my servers insist on creating the "common" environment and restarting puppetserver service, but my r10k runs remove this environment.

Is there a way to disable the creating of this environment?

@ekohl
Copy link
Member

ekohl commented Feb 21, 2020

You can set puppet::server_common_modules_path to an empty string

@cabrinha
Copy link
Contributor

You can set puppet::server_common_modules_path to an empty string

Thanks for the quick reply... What would happen if I just set it to:

/etc/puppetlabs/code/modules?

@ekohl
Copy link
Member

ekohl commented May 12, 2020

That would work as well.

optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Sep 20, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.
- The config_version_cmd is updated to use only the first listed directory from
  `envs_dir`, this is only used in the environment.conf.erb template which does
  not appear to be deployed anywhere in the current version of this module

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
@optiz0r
Copy link
Contributor

optiz0r commented Sep 20, 2021

I find myself wanting this functionality so that I can have r10k manage environments that have been committed to git, but also have some other environments present on the puppetserver which are not managed by r10k. r10k will purge unknown environments, and I don't believe this behaviour is configurable. One workaround is to have the puppetserver use two environmentpath directories, only one of which is managed by r10k, and the other contains the unmanaged environments.

I have implemented support for envs_dir to contain multiple colon-separated paths as described in this issue. I've not been able to properly test installing the updated module from git into the foreman puppet modules directory, but by manually applying the patch from this commit over the top of the files foreman-installer puts down on disk, these changes do work at least for the foreman-installer options I'm using. I've added some additional spec tests to validate the multiple envs_dir behaviour, and confirmed that all other related tests still pass. I'm seeing some tests fail relating to cron resources when running the tests locally, but I'm hoping this is just a local environment issue and these will pass when the PR is tested under CI. I will need someone to approve the CI workflow to know if that's the case.

One of the references to envs_dir parameter is interpolation into the config_version_cmd variable, which is itself used in the environment.conf.erb template, however, I cannot spot any references to this template actually being deployed by the current manifests. Is that template obsolete?

@ekohl
Copy link
Member

ekohl commented Sep 21, 2021

One of the references to envs_dir parameter is interpolation into the config_version_cmd variable, which is itself used in the environment.conf.erb template, however, I cannot spot any references to this template actually being deployed by the current manifests. Is that template obsolete?

Looks like its use was removed in a61e010 and I forgot the actual template and parameter. I'd prefer to remove them and not get into the business of directly managing environments in this module. I'd also love a PR for this :)

optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Sep 21, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Sep 21, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Multiple directories are passed as an Array of Stdlib::Absolutepath
values. For backwards compatibility, a single string is also accepted, and converted
into a single-element array on each use.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
Depends on theforeman#805
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Sep 21, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Multiple directories are passed as an Array of Stdlib::Absolutepath
values. For backwards compatibility, a single string is also accepted, and converted
into a single-element array on each use.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
Depends on theforeman#805
@optiz0r
Copy link
Contributor

optiz0r commented Sep 21, 2021

PR for dropping the config_version related parameters in #805. PR #803 is dependent on #805, and has been updated to use the string or array, rather than colon-separated string.

I'm still seeing spec tests fail on cron resources, but I haven't touched anything relating to that, so I'm not sure why that's happening. Looking at previous commits, there seem to be various CI failures, though not relating to cron either. (Edit: master branch is also showing the cron failures, so definitely not related to the changes in my PRs)

optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Oct 14, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.
- The config_version_cmd is updated to use only the first listed directory from
  `envs_dir`, this is only used in the environment.conf.erb template which does
  not appear to be deployed anywhere in the current version of this module

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Oct 14, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Multiple directories are passed as an Array of Stdlib::Absolutepath
values. For backwards compatibility, a single string is also accepted, and converted
into a single-element array on each use.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
Depends on theforeman#805
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Oct 14, 2021
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Multiple directories are passed as an Array of Stdlib::Absolutepath
values. For backwards compatibility, a single string is also accepted, and converted
into a single-element array on each use.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed, and that any other references to the envs_dir parameter behave the
same as if only a single directory were specified to maintain backward
compatibility.

Fixes theforeman#708
Depends on theforeman#805
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Feb 4, 2022
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Directories (whether one, or multiple) are passed as an
Array of Stdlib::Absolutepath values.

This is a breaking change, as a single string will no longer be accepted.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed.

Fixes theforeman#708
Depends on theforeman#805
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Feb 4, 2022
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Directories (whether one, or multiple) are passed as an
Array of Stdlib::Absolutepath values.

This is a breaking change, as a single string will no longer be accepted.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed.

Fixes theforeman#708
optiz0r added a commit to optiz0r/puppet-puppet that referenced this issue Feb 5, 2022
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Directories (whether one, or multiple) are passed as an
Array of Stdlib::Absolutepath values.

This is a breaking change, as a single string will no longer be accepted.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed.

Fixes theforeman#708
@ekohl ekohl closed this as completed in #803 Feb 5, 2022
ekohl pushed a commit that referenced this issue Feb 5, 2022
This module adds support for the puppet environmentpath setting to be configured
using multiple directories. An example use-case is where r10k is in use to
deploy some but not all environments, to avoid unmanaged environments being
purged by r10k. Directories (whether one, or multiple) are passed as an
Array of Stdlib::Absolutepath values.

This is a breaking change, as a single string will no longer be accepted.

- Each listed environmentpath directory will be created and managed by puppet
- The default post-receive hook script uses the first listed directory in
  `envs_dir` to create initial environments to maintain backward compatibility.

Tests are included to ensure that all listed directories are created and
managed.

Fixes #708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants