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 envs_dir directories #803

Merged
merged 1 commit into from
Feb 5, 2022

Conversation

optiz0r
Copy link
Contributor

@optiz0r optiz0r commented 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 #708

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping the data type of envs_dir on Stdlib::Absolutepath is misleading. If it's an array, really make it an array: Variant[Array[Stdlib::Absolutepath, 1], Stdlib::Absolutepath].

@optiz0r
Copy link
Contributor Author

optiz0r commented Sep 23, 2021

I think keeping the data type of envs_dir on Stdlib::Absolutepath is misleading. If it's an array, really make it an array: Variant[Array[Stdlib::Absolutepath, 1], Stdlib::Absolutepath].

A wrinkle: this is going to need corresponding changes to the foreman-installer too, which currently takes a single string parameter and passes it straight through. This also introduces a potential compatibility break between newer versions of the foreman-installer and older versions of this puppet module, where a newer installer would pass an array but an older puppet module would only accept a string. Would that be a major concern?

@ekohl
Copy link
Member

ekohl commented Oct 19, 2021

That's why I suggested a Variant. That would accept both a string and an array.

@optiz0r
Copy link
Contributor Author

optiz0r commented Oct 19, 2021

I didn't mean on the puppet module side, the actual foreman installer which uses this module only knows how to pass a string at the moment. It does not know how to pass an array. The change in behaviour to pass an array of strings instead might be breaking, particularly considering both forwards and backwards compatibility.

@ekohl
Copy link
Member

ekohl commented Oct 20, 2021

I think it should handle a Variant already but it's a good point that it should be tested. We can also only accept an array and make write a migration. That may be easier in the code too and we're doing a backwards incompatible release next anyway.

@ekohl
Copy link
Member

ekohl commented Feb 4, 2022

I'm very close to releasing a major version of the module. Would you like to update this so it's an array? I can write the migration on the installer side.

@optiz0r
Copy link
Contributor Author

optiz0r commented Feb 4, 2022

@ekohl Do you mean switch from Variant[Array[Stdlib::Absolutepath, 1], Stdlib::Absolutepath] to just Array[Stdlib::Absolutepath, 1]? If so yes, I can do that this weekend.

@ekohl
Copy link
Member

ekohl commented Feb 4, 2022

That is indeed what I mean. I can wait with a major version until Monday.

@optiz0r
Copy link
Contributor Author

optiz0r commented Feb 4, 2022

Updated to drop taking a single path as a string (breaking change), and rebased against current master.

I've been monkey patching a variant of this change that takes multiple paths as colon-separated strings, since the foreman-installer only passes the arg as a string. I am running foreman nightly, so if you are able to update the installer to pass an array, I'm happy to try testing that against this branch before you roll a release to confirm all working as expected.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor thing, other than that 👍

Comment on lines 234 to 241
$puppet::server::envs_dir.each |$dir| {
file { $dir:
ensure => $ensure,
owner => $puppet::server::environments_owner,
group => $puppet::server::environments_group,
mode => $puppet::server::environments_mode,
target => $puppet::server::envs_target,
force => true,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to modify this since you can pass an array to file.

@ekohl
Copy link
Member

ekohl commented Feb 4, 2022

I think theforeman/foreman-installer#740 would be the installer migration.

@optiz0r
Copy link
Contributor Author

optiz0r commented Feb 4, 2022 via email

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
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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

Successfully merging this pull request may close these issues.

Support multiple path in environmentpath parameter
3 participants