Closed chrisolsen closed 11 years ago
Does package_path read in the template contents?
I'm feeling a need to completely rethink file rendering to be more like puppet (much more explicit):
file '/etc/apache2/apache2.conf',
:sudo => true,
:content => template(template_dir.join('apache2.conf.erb'), binding),
:mode => '644'
Then at least you could quickly stash the md5 in a local variable and use it for an md5 check inside verify... and transfer would stick to scping files... the way to push a single file into place would be to use "file".
Ultimately there needs to be a little more cross talk between installers and verifiers... like an auto-verify option...but then it's possible that not every step along the way needs to be verified... hate to start sticking autoverify: true on everything... it sure would help in cases like this though.
Does package_path read in the template contents? Close, it is just a custom helper method that returns the full template path
Ultimately there needs to be a little more cross talk between installers and verifiers I agree
If it returns only the path then aren't you missing a :render?
I am, looks like I forgot it when I was manually reverting things back after making some attempts to do the check. Sorry for the confusion.
What do you think of the commented out suggestion? Would that work?
matches_local src, dest, render: true, locals: locals
The right way to do something like you are asking:
package :nginx_conf do
@nginx_port = 8080
nginx_config = render("nginx.conf")
file '/etc/nginx.conf',
:contents => nginx_config
verify do
md5_of_file "/etc/nginx.conf", md5(nginx_config)
end
end
transfer :render
will be depreciated in 0.8 and file
is the new way to do these type of things.
Or maybe 0.9 since this wont likely hit the gem until later.
We could support passing locals as well, though I think you should look at the new defaults functionality we're adding... I wonder if it could help simplify your setup any.
The branch I'm working on: https://github.com/sprinkle-tool/sprinkle/tree/file_installer
And it's back in master now.
The latest render() now supports passing locals as the second argument... see rendering.rb. Closing this issue.
Although keep in mind if supplying that second argument, the instance variables from the package won't be bound to the template anymore.
Yeah, I think that would be understood.
We'd have to jump thru more hoops if we wanted locals to be additive instead of replacing context.
I can't seem to find a good way to verify matching files on the server after using the transfer method with render: true.