Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Puppet-如果源不可用,则以静默方式退出_Puppet - Fatal编程技术网

Puppet-如果源不可用,则以静默方式退出

Puppet-如果源不可用,则以静默方式退出,puppet,Puppet,如果源文件不可用,是否可以静默退出 例如: file {"/tmp/skin-${version}_${theme}.zip": source => "${file_location}/skin-${version}_${theme}.zip", ensure => file, mode => '0700' } -> exec {"commands": Here I will be pr

如果源文件不可用,是否可以静默退出

例如:

file {"/tmp/skin-${version}_${theme}.zip":
        source => "${file_location}/skin-${version}_${theme}.zip",
        ensure  => file,
        mode    => '0700'
    }
->
exec {"commands":  
         Here I will be processing the above downloaded file, if the url is not valid this block should not execute.
    }
在上面的示例中,如果文件->源url不可用,则应无提示地退出,不会出现任何错误。

如果在exec上执行,则只有在测试成功时才会触发

  exec { 'command':
    onlyif => "test -f /tmp/skin-${version}_${theme}.zip"
  }

此文件的宿主位置是哪里?如果它在模块中,那么它什么时候不存在?是的,它在模块中。假设在
skin.pp
文件中,代码在class
dev:skin\u it
中,它是从其他模块调用的。那么该文件将始终存在于模块内的
files
目录中,因此您很好。在运行时,我可以在控制台上看到错误,我希望给出正确的消息(notify)而不是错误。修复错误怎么样?${file_location}是一个url,test命令对url有效吗?不,抱歉,我读过头了。您必须检查文件以便进行测试:
“test-f/tmp/skin-${version}{theme}.zip”