简体   繁体   中英

chef template/statements with remote_file

I'm trying to create a chef script which downloads a file & pass the content of the downloaded file to template variables using IO.read(downloaded File), which internally download multiple files. Downloaded file has a specific format such as filename, url, checksum, etc. I need to make use of remote_file again inside template based on the data of the first remote_file.

Since the remote file doesn't exist, I get a compile time error

Errno::ENOENT
-------------
No such file or directory @ rb_sysopen - ....

Any suggestions to solve my use case?

You need to delay the file read until converge time due to the two-pass model. Read https://coderanger.net/two-pass/ for details on what the two-pass model is. In this case you probably want something like variables foo: lazy { IO.read('something') } (assuming you are running Chef 13).

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