Skip to content

Commit 964f110

Browse files
ekohlmmoll
authored andcommitted
Fixes #26199 - Fix dependency cycle when using git_repo
Previously this resulted in a dependency cycle. The tests didn't compile so didn't catch it. dependency cycles found: (File[/opt/puppetlabs/puppet/cache] => Class[Puppet::Server::Install] => Class[Puppet::Server::Config] => File[/opt/puppetlabs/puppet] => File[/opt/puppetlabs/puppet/cache]) a61e010 introduced this by managing $sharedir in puppet::server::config. $vardir was managed in puppet::server::install. Since sharedir is actually /opt/puppetlabs/puppet and vardir is the cache directory within that, it created a cycle.
1 parent e8c133e commit 964f110

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

manifests/server/config.pp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,25 @@
232232
}
233233

234234
if $::puppet::server::git_repo {
235-
# need to chown the $vardir before puppet does it, or else
236-
# we can't write puppet.git/ on the first run
237-
238235
include ::git
239236

237+
if $::puppet::server::manage_user {
238+
Class['git'] -> User[$::puppet::server::user]
239+
}
240+
241+
file { $::puppet::vardir:
242+
ensure => directory,
243+
owner => 'root',
244+
group => 'root',
245+
}
246+
240247
git::repo { 'puppet_repo':
241248
bare => true,
242249
target => $::puppet::server::git_repo_path,
243250
mode => $::puppet::server::git_repo_mode,
244251
user => $::puppet::server::git_repo_user,
245252
group => $::puppet::server::git_repo_group,
246-
require => File[$::puppet::server::envs_dir],
253+
require => File[$::puppet::vardir, $::puppet::server::envs_dir],
247254
}
248255

249256
$git_branch_map = $::puppet::server::git_branch_map

manifests/server/install.pp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,4 @@
3737
Package[$server_package] -> User[$::puppet::server::user]
3838
}
3939
}
40-
41-
if $::puppet::server::git_repo {
42-
Class['git'] -> User[$::puppet::server::user]
43-
44-
file { $puppet::vardir:
45-
ensure => directory,
46-
owner => $::puppet::server::user,
47-
group => $::puppet::server::group,
48-
}
49-
}
5040
}

spec/classes/puppet_server_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@
345345
super().merge(server_git_repo: true)
346346
end
347347

348+
it { is_expected.to compile.with_all_deps }
349+
348350
it do
349351
should contain_class('puppet::server')
350352
.with_git_repo(true)
@@ -373,7 +375,7 @@
373375
it do
374376
should contain_file(vardir)
375377
.with_ensure('directory')
376-
.with_owner('puppet')
378+
.with_owner('root')
377379
end
378380

379381
it do

0 commit comments

Comments
 (0)