I want to install a Tomcat-Server onto a Windows node and then Copy a modified server.xml so the configuration is already done.
At this point, it is easily done with Chef and windows cookbook:
recipes/default.rb
windows_zipfile node['tomcat']['install_dir'] do
source node['tomcat']['url']
action :unzip
not_if {::Dir.exists?(node['tomcat']['dir'])}
end
cookbook_file 'server.xml' do
path "#{node['tomcat']['dir']}conf/server.xml"
action :create
end
Now the tricky part: The user should be allowed to change the server.xml! When he does this and the chef-client runs, it would overwrite the user-change server.xml and put back the given cookbook file. But this must not happen. The file should be copied only after successful unzipping the Tomcat Server.
So i think I definitely need a not_if/only_if statement.
Like somthing to verify the cookbook file is installed only at tomcat unzip time. Is there any way to say "only_if windows_zipfile was executed" or something like that?
Or should I maybe compare the length of the server.xml (of the node) and only replace it with the cookbook file, if the length matches the length of the unmodified standard server.xml of installation? (<== this sounds creepy)
The given actions for windows_zipfile doesn't help here I guess...
Thank you in advance
Bohne