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

Fixes #35983 - Permit recursive ownership/permissions for environments #861

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@
#
# $server_environments_mode:: Environments directory mode.
#
# $server_environments_recurse:: Should the environments directory be managed recursively
#
# $server_common_modules_path:: Common modules paths
#
# $server_git_repo_path:: Git repository path
Expand Down Expand Up @@ -671,6 +673,7 @@
String $server_environments_owner = $puppet::params::server_environments_owner,
Optional[String] $server_environments_group = $puppet::params::server_environments_group,
Pattern[/^[0-9]{3,4}$/] $server_environments_mode = $puppet::params::server_environments_mode,
Boolean $server_environments_recurse = $puppet::params::server_environments_recurse,
Array[Stdlib::Absolutepath, 1] $server_envs_dir = $puppet::params::server_envs_dir,
Optional[Stdlib::Absolutepath] $server_envs_target = $puppet::params::server_envs_target,
Variant[Undef, String[0], Array[Stdlib::Absolutepath]] $server_common_modules_path = $puppet::params::server_common_modules_path,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
$server_environments_owner = $user
$server_environments_group = $root_group
$server_environments_mode = '0755'
$server_environments_recurse = false
# Where we store our puppet environments
$server_envs_dir = ["${codedir}/environments"]
$server_envs_target = undef
Expand Down
3 changes: 3 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
#
# $environments_mode:: Environments directory mode.
#
# $environments_recurse:: Should the environments directory be managed recursively
#
# $envs_dir:: List of directories that hold puppet environments
# All listed directories will be created and attributes managed,
# but only the first listed path will be used to populate
Expand Down Expand Up @@ -381,6 +383,7 @@
String $environments_owner = $puppet::server_environments_owner,
Optional[String] $environments_group = $puppet::server_environments_group,
Pattern[/^[0-9]{3,4}$/] $environments_mode = $puppet::server_environments_mode,
Boolean $environments_recurse = $puppet::server_environments_recurse,
Array[Stdlib::Absolutepath, 1] $envs_dir = $puppet::server_envs_dir,
Optional[Stdlib::Absolutepath] $envs_target = $puppet::server_envs_target,
Variant[Undef, String[0], Array[Stdlib::Absolutepath]] $common_modules_path = $puppet::server_common_modules_path,
Expand Down
13 changes: 7 additions & 6 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@
}

file { $puppet::server::envs_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,
ensure => $ensure,
owner => $puppet::server::environments_owner,
group => $puppet::server::environments_group,
mode => $puppet::server::environments_mode,
target => $puppet::server::envs_target,
recurse => $puppet::server::environments_recurse,
force => true,
}

if $puppet::server::git_repo {
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/puppet_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
.with_ensure('directory')
.with_owner('puppet')
.with_group(nil)
.with_recurse(false)
.with_mode('0755')

should contain_file(sharedir).with_ensure('directory')
Expand Down Expand Up @@ -405,6 +406,11 @@
it { should contain_file(environments_dir).with_owner('apache') }
end

context 'with directory environments recursive mangement' do
let(:params) { super().merge(server_environments_recurse: true) }
it { should contain_file(environments_dir).with_recurse(true) }
end

context 'with no common modules directory' do
let(:params) { super().merge(server_common_modules_path: '') }
it { should_not contain_puppet__config__main('basemodulepath') }
Expand Down