ska*_*ana 6 puppet puppetmaster
我正在尝试创建一个函数,仅当第一个目录存在时才会创建目录/文件,而不是因为依赖失败而必须跳过它。
我已经尝试过这种“onlyif”解决方法,但不幸的是它不适用于我的功能。
$check_directory = file("/path/to/directory")
if($check_directory != '') {
file{"/path/to/config":
ensure => directory,
mode => 0755,
}
file{"/path/to/config/a.conf":
ensure => file,
mode => 0755,
content => template("config_template.conf"),
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
Error: Is a directory - /path/to/directory
Run Code Online (Sandbox Code Playgroud)
有没有办法做任何其他 if 语句?或者什么参数?谢谢。
您应该能够简单地require
在a.conf
文件资源中使用语句:
file{"/path/to/directory":
ensure => directory,
mode => 0755,
}
file{"/path/to/config":
ensure => directory,
mode => 0755,
}
file{"/path/to/config/a.conf":
ensure => file,
mode => 0755,
content => template("config_template.conf"),
require => File["/path/to/directory"],
}
Run Code Online (Sandbox Code Playgroud)
这将确保在文件之前创建目录。
归档时间: |
|
查看次数: |
23118 次 |
最近记录: |