Error: Could not apply complete catalog: Found 1 dependency cycle

Error: Could not apply complete catalog: Found 1 dependency cycle

当运行以下命令时:

puppet apply --verbose /etc/puppet/manifests/sites.pp/site1.pp

我收到错误:

Error: Could not apply complete catalog: Found 1 dependency cycle:
(File[/etc/postfix] => File[/etc/postfix])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz

这是相关的 manifest/modules:

/etc/puppet/modules/postfix/manifests/init.pp:

class postfix {

    package { 'postfix' :
        ensure => present
    }

    file { '/etc/postfix' :
        path => "/etc/postfix/main.cf",
        ensure => present,
        content => template("postfix/main.cf.erb"),
        subscribe => Package['postfix']
    }

}

/etc/puppet/manifests/sites.pp/site1.pp:

class site1 {

    include apache2
    include essentials
    include mysql
    include python2
    include postfix
}

在任何其他模块中都没有提到 postfix,删除 include postfix 允许完整的 puppet apply 继续,所以我假设它是独立的。

我也试过删除模板并将占位符内容放入模块本身,但没有任何变化。

出于某种原因,您使用的路径与资源名称不同。这会导致 self 的自动包含和循环依赖。

file { '/etc/postfix' :
    ensure=>directory
}
file { '/etc/postfix/main.cf':
    ensure => present,
    content => template("postfix/main.cf.erb"),
    subscribe => Package['postfix']
}

将解决您的问题