通过在Puppet中创建和读取文件进行排序

通过在Puppet中创建和读取文件进行排序,puppet,Puppet,我知道这是与目录有关的问题,我只是不知道如何解决它 我有以下代码,我得到以下错误: class test1 { file { '/tmp/test.txt': ensure => present, content => 'name=joe', } } class test2 { $test = file('/tmp/test.txt') notify { $test: } } class test3 { class { 'test1': }

我知道这是与目录有关的问题,我只是不知道如何解决它

我有以下代码,我得到以下错误:

class test1 {
  file { '/tmp/test.txt':
    ensure  => present,
    content => 'name=joe',
  }
}

class test2 {
  $test = file('/tmp/test.txt')
  notify { $test: }
}

class test3 {
  class { 'test1': } ->
  class { 'test2': }
}

puppet apply -e "include test3"

Error: Could not find any files from test.txt at ../modules/test2/manifests/init.pp

所以本质上,我试图在文件存在之前读取它,而排序似乎不起作用。有什么办法可以解决这个问题吗?

根据您尝试使用的功能的描述,它永远不会以您尝试的方式运行


从模块加载文件并以字符串形式返回其内容

实际上,这意味着该文件将存在于

test1/files/test.txt

并将使用以下方式加载:
文件('test1/test.txt')
文件(/)

我应该指出该文件是通过其绝对路径加载到“file”函数中的:即文件('/tmp/test.txt')