При печати файлов PostScript Вы действительно не можете сказать, сколько страницы будут распечатаны, не интерпретируя файл и считая ими. При необходимости в этом можно изменить спулер, чтобы стать всего страниц распечатанными от systemdict прежде и после задания и использовать различие.
Принтеры неPS могут отличаться.
Можете ли вы использовать блок bash?
http://wiki.opscode.com/display/chef/Resources#Resources-Script
Итак, что-то вроде:
bash "append_to_config" do
user "root"
cwd "/path/to/config/directory"
code <<-EOH
echo "#{node[:array_of_hashes][:hash_key]}=#{node[:array_of_hashes][:hash_value]}" > my_config.conf
EOH
end
Плюс любые циклы, условия и т. Д., Которые вам понадобятся для работы.
This isn't strictly built into Chef as a feature of the library or any of the resources because when managing system state it is better and more reliable to manage the whole contents of a file. If the content of the template is modified elsewhere in another cookbook, consider why that is and if it may be sensible to consolidate the recipes.
You can also use a nifty feature to "reopen" a defined resource - the resources
method can be used to select particular resource. Very basic example:
That said, the Chef::Util::FileEdit
class has a number of helper methods for managing content. The ticket that originally implemented the feature is CHEF-78. It isn't documented (sorry) for reasons I mentioned above. There is a patch to further extend this library to append a line if it doesn't exist, which is under ticket CHEF-2740. You may be able to achieve the results you want with the existing library's methods.