简体   繁体   中英

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

And would be loaded using: file('test1/test.txt') ie file(<MODULENAME>/<FILENAME>)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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