我已经查找了使用虚拟资源订购的示例,但我无法找到。如何设置依赖关系/顺序?这无法进行语法检查:
@file { "/usr/local/new-dir":
ensure => directory,
}
realize( File["/usr/local/new-dir"] )
->
exec { "copy old stuff to new":
command => "cp -R /usr/local/old-dir /usr/local/new-dir",
}
并测试语法:
$ puppet parser validate test.pp
err: Could not parse for environment production: Syntax error at '->' at /home/vagrant/test.pp:6
err: Try 'puppet help parser validate' for usage
我可以想很多次我想订购虚拟资源,那么它是如何完成的?
非常感谢任何帮助或见解。
答案 0 :(得分:3)
您可以使用收集器而不是实现,然后应用排序:
@file { "/usr/local/new-dir":
ensure => directory,
}
exec { "copy old stuff to new":
command => "cp -R /usr/local/old-dir /usr/local/new-dir",
}
File <| title == "/usr/local/new-dir" |> -> Exec["copy old stuff to new"]
答案 1 :(得分:2)
这也有效:
@file { "/usr/local/new-dir":
ensure => directory,
}
realize( File["/usr/local/new-dir"] )
exec { "copy old stuff to new":
command => "cp -R /usr/local/old-dir /usr/local/new-dir",
require => File["/usr/local/new-dir"],
}
我通常认为优先require/before
元参数优于->
链接运算符是一种很好的做法。但那只是我。