人偶在文件 class 和定义之间创建关系
puppet creating relationship between file, class and define
我想在文件之间创建关系,class 并定义...。请检查以下代码...。
我面临的问题是,即使 deploy.cfg 文件没有变化,class 和 nexus::artifact 总是运行...
class 和 nexus::artifact 只有在检测到文件
发生变化时才应该执行
我知道我们需要使用 subscribe 和 refreshonly=true。但是我不知道把它放在哪里...
file { 'deploy.cfg':
ensure => file,
path => '/home/deploy/deploy.cfg',
mode => '0644',
owner => 'root',
group => 'root',
content => "test",
notify => [Class['nexus'], Nexus::Artifact['nexus-artifact']],
subscribe => File['/home/deploy/dir'],
}
class { 'nexus':
url => $url,
username => $user,
password => $password,
}
nexus::artifact { "nexus-artifact":
gav => $gav,
packaging => $packaging,
output => $targetfilepath,
repository => $repository,
owner => $owner,
mode => $mode,
}
artifact.pp
define nexus::artifact (
$gav,
$repository,
$output,
$packaging = 'jar',
$classifier = undef,
$ensure = update,
$timeout = undef,
$owner = undef,
$group = undef,
$mode = undef
) {
include nexus
}
init.pp
class nexus (
$url,
$username = undef,
$password = undef,
$netrc = undef,
) {
}
even if there is no change in deploy.cfg file, class and nexus::artifact always runs
是的,每个 class 节点目录中的资源都会应用于每个目录 运行,除非需要应用的资源在它失败之前。那是正常的。在这方面要理解的关键是,应用目录资源的第一部分是确定相应的物理资源是否已经同步;如果是,则应用目录资源没有进一步的效果。
class and nexus::artifact should execute only if it detects a change in file
I know that we need to make use of subscribe and refreshonly=true.
嗯,不。您可以调整应用 class 和资源的 效果 ,但您不能使用同步另一个资源的结果来调整它们是否被应用。无论如何,refreshonly
特定于 Exec
资源,而您的代码中没有任何这些资源。
我想在文件之间创建关系,class 并定义...。请检查以下代码...。 我面临的问题是,即使 deploy.cfg 文件没有变化,class 和 nexus::artifact 总是运行...
class 和 nexus::artifact 只有在检测到文件
发生变化时才应该执行我知道我们需要使用 subscribe 和 refreshonly=true。但是我不知道把它放在哪里...
file { 'deploy.cfg':
ensure => file,
path => '/home/deploy/deploy.cfg',
mode => '0644',
owner => 'root',
group => 'root',
content => "test",
notify => [Class['nexus'], Nexus::Artifact['nexus-artifact']],
subscribe => File['/home/deploy/dir'],
}
class { 'nexus':
url => $url,
username => $user,
password => $password,
}
nexus::artifact { "nexus-artifact":
gav => $gav,
packaging => $packaging,
output => $targetfilepath,
repository => $repository,
owner => $owner,
mode => $mode,
}
artifact.pp
define nexus::artifact (
$gav,
$repository,
$output,
$packaging = 'jar',
$classifier = undef,
$ensure = update,
$timeout = undef,
$owner = undef,
$group = undef,
$mode = undef
) {
include nexus
}
init.pp
class nexus (
$url,
$username = undef,
$password = undef,
$netrc = undef,
) {
}
even if there is no change in deploy.cfg file, class and nexus::artifact always runs
是的,每个 class 节点目录中的资源都会应用于每个目录 运行,除非需要应用的资源在它失败之前。那是正常的。在这方面要理解的关键是,应用目录资源的第一部分是确定相应的物理资源是否已经同步;如果是,则应用目录资源没有进一步的效果。
class and nexus::artifact should execute only if it detects a change in file
I know that we need to make use of subscribe and refreshonly=true.
嗯,不。您可以调整应用 class 和资源的 效果 ,但您不能使用同步另一个资源的结果来调整它们是否被应用。无论如何,refreshonly
特定于 Exec
资源,而您的代码中没有任何这些资源。