Puppet错误:无法打开下载的文件

Puppet错误:无法打开下载的文件,puppet,Puppet,编辑:添加了filebeat::install\u filebeat类的内容 我的puppet模块中有两个类,类filebeat和类filebeat::install\u filebeat继承filebeat 在filebeat类中,我想下载一个属性文件并将其保存在特定路径中,因此我要: exec{ 'get_properties_file': command => "/usr/bin/curl -o ${properties_path} '${download_url}'", creat

编辑:添加了filebeat::install\u filebeat类的内容

我的puppet模块中有两个类,类filebeat和类filebeat::install\u filebeat继承filebeat

在filebeat类中,我想下载一个属性文件并将其保存在特定路径中,因此我要:

exec{ 'get_properties_file':
command => "/usr/bin/curl -o ${properties_path} '${download_url}'",
creates => $properties_path,
}

file{ $properties_path:
mode    => '644',
target  => $properties_path 
require => Exec["get_properties file"],
}
这工作正常,文件下载到$properties\u路径

然后在我的类filebeat::install\u filebeat中,我有:

class filebeat::install_filebeat inherits filebeat{

  $file = file($properties_path)
  $file = file($properties_path)
  $properties_lines = split( $file, '\r')
  $host_line = grep($properties_lines, '^host=.*')
  $token_line = grep($properties_lines, '^token=.*')
  $host_splited = split($host_line[0], '=')
  $token_splited = split($token_line[0], '=')
  $token = join(delete_at($token_splited,0),"=")
  $host = join(delete_at($host_splited,0),"=")

  file { '/etc/filebeat/filebeat.yml':
    ensure  => 'present',
    owner   => 'root',
    group   => 'root',
    mode    => '644',
    purge   => true,
    content => template("filebeat/${filebeat_template}"),
  }

  service { 'filebeat':
    ensure     => running,
    enable     => true,
    hasstatus  => true,
    hasrestart => true,
 }

File['/etc/filebeat/filebeat.yml'] -> Service['filebeat'] 
}
如果文件在上一次执行时已保存在$properties\u路径中,但我试图通过在类中添加filebeat一次完成所有操作时,则此方法效果良好 包括filebeat::安装\u filebeat

我不断得到错误: “错误:在[properties\u path]中找不到任何文件。

在我看来,puppet试图在下载之前先完成文件($properties\u path),但我真的不知道如何解决它


任何帮助都将是可怕的

这个傀儡有没有使用代理?没有代理,我没有主控,只在本地运行。OK,那么这里只有一个问题,那就是函数在目录编译期间执行,但是函数参数中的文件在目录执行之前不存在。你必须用另一种方法来解决这个问题。但是,例如,当我发送一个包时,我可以安装它并在同一目录中启动服务。。这不是对我的文件所做的更改吗?我怎么能告诉函数之前需要资源文件?好的,对不起,如果我不理解它,我不是故意打扰你。这个木偶是否使用代理?没有代理,我没有主控,只在本地运行它。Ok,那么你这里只有一个问题,那就是该函数是在目录编译期间执行的,但函数参数中的文件在目录执行之前不存在。你必须用另一种方法来解决这个问题。但是,例如,当我发送一个包时,我可以安装它并在同一目录中启动服务。。这不是对我的文件所做的更改吗?我怎样才能告诉函数之前需要资源文件?好的,如果我不理解,很抱歉,我不是有意打扰你的