Skip to content

Commit

Permalink
Fixes #26199 - Fix dependency cycle when using git_repo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ekohl committed Feb 28, 2019
1 parent e8c133e commit 5ca9a3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
15 changes: 11 additions & 4 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,25 @@
}

if $::puppet::server::git_repo {
# need to chown the $vardir before puppet does it, or else
# we can't write puppet.git/ on the first run

include ::git

if $::puppet::server::manage_user {
Class['git'] -> User[$::puppet::server::user]
}

file { $::puppet::vardir:
ensure => directory,
owner => 'root',
group => 'root',
}

git::repo { 'puppet_repo':
bare => true,
target => $::puppet::server::git_repo_path,
mode => $::puppet::server::git_repo_mode,
user => $::puppet::server::git_repo_user,
group => $::puppet::server::git_repo_group,
require => File[$::puppet::server::envs_dir],
require => File[$::puppet::vardir, $::puppet::server::envs_dir],
}

$git_branch_map = $::puppet::server::git_branch_map
Expand Down
10 changes: 0 additions & 10 deletions manifests/server/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,4 @@
Package[$server_package] -> User[$::puppet::server::user]
}
}

if $::puppet::server::git_repo {
Class['git'] -> User[$::puppet::server::user]

file { $puppet::vardir:
ensure => directory,
owner => $::puppet::server::user,
group => $::puppet::server::group,
}
}
}
2 changes: 2 additions & 0 deletions spec/classes/puppet_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@
super().merge(server_git_repo: true)
end

it { is_expected.to compile.with_all_deps }

it do
should contain_class('puppet::server')
.with_git_repo(true)
Expand Down

0 comments on commit 5ca9a3a

Please sign in to comment.