I'd like to examine the division between the "file", "remote_file" and
"tempate" resources.
First of all, they are badly named. Why isn't there a remote_template to
correspond with remote_file? What's "remote" about remote_file in Chef Solo?
Can we at least rename the little-used "file" to be "file_touch" so we can use
"file" instead of "remote_file" everywhere?
Second, the 3 types are similar in my mind because the 'flow' of data is 99.9%
the same: "I need a file to exist on disk right HERE (with or without an ERB
step)".
My current workflow looks like this: I start off by copying a config file into
"/files" and create a "remote_file" resource. But then I discover I need an
attribute in the config file, so I have to move the config file (from "/files"
to "/templates") and change the resource type (from "remote_file" to
"template") and sometimes edit the name (from "config" to "config.erb").
Sometimes I break up the config file to sub-configs. But these go into
different directories depending on if they need ERB attributes or not.
Logically, the sub-configs should be siblings, but physically they go in
different directories. Sometimes I find myself moving the files back and forth
as I refactor the config file and sub-config files and move attributes around.
It would make more sense to set an attribute ("oh, by the way, that file needs
ERB now") on the existing resource. I also think it's better if I don't have to
move the file from /files to /templates.
Imagine merging these resources into one "file" resource:
# touch a file
file "/tmp/touch_me" do
action :touch
end
# copy file
file "/tmp/blob" do
# source "blob" is implicit. Looks in /files/default/blob
end
# Some files are so small, it's silly to create a
# new file in a new directory just to hold the contents
file "/tmp/blob" do
contents "dude"
end
# Some generated files don't benifit from ERB.
file "database.yml" do
contents do @node.database_settings.to_yaml; end
end
# switching from a static file to a template
# shouldn't require a new resource.
file "/tmp/blob" do
filter :erb # process source file with ERB
# Not sure if it should default to source 'blob' or 'blob.erb'
# also not sure if it should look in /templates or just in /files
end
I know it's a major change, but hey, now is the time for big changes, right?
What do you think?
-=Dan=-
Archive powered by MHonArc 2.6.16.