简体   繁体   English

在Puppet中创建和读取文件的顺序

[英]Ordering with creating and reading a file in Puppet

I know it is something with the catalog that is the issue, I just can't figure out how to work around it. 我知道问题出在目录中,我只是想不通如何解决。

I have the following code and I get the following error: 我有以下代码,并且出现以下错误:

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

So essentially, I am trying to read a file before it exists, and the ordering doesn't appear to be working. 因此,从本质上讲,我试图在文件存在之前读取文件,并且该顺序似乎不起作用。 Any ideas how I can work around this? 有什么想法可以解决这个问题吗?

Based on the description of the function you are trying to utilize it will never operate in the fashion you are trying. 根据您要使用的功能的描述,它永远不会以您尝试的方式运行。

file: 文件:
Loads a file from a module and returns its contents as a string. 从模块加载文件并以字符串形式返回其内容。

Affectively what this means is that the file would exist in 有意义的是,该文件将存在于

test1/files/test.txt test1 / files / test.txt

And would be loaded using: file('test1/test.txt') ie file(<MODULENAME>/<FILENAME>) 并使用以下file('test1/test.txt')加载: file('test1/test.txt')file(<MODULENAME>/<FILENAME>)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM