我正在尝试创建一个函数,仅当第一个目录存在时才会创建目录/文件,而不是因为依赖失败而必须跳过它。
我已经尝试过这种“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 语句?或者什么参数?谢谢。