How to combine remote_directory and template resource together

Hi

In my use-case , I want to copy folder and modified some files into a
folder.

To copy a folder i used remote_directory and put folder in to files/default
folder . then create template file and put this file in to same folder on
destination machines .

the above scenario is working fine but only problem i am facing is every
time once chef-client run folder is updated . because firstly i copied a
folder using remote directory and use template to modify files . so every
time folder on destination system is change

so is there any other approach to write cookbook in above scenario so my
folder will not update at every time when chef-client runs

Regards
Prateek

Post your recipe, or at least the exact way how you call remote_directory and template resources.

Chris

The underlying problem is that the remote directory checks whether it has been changed, and if it has, then it will try to restore the original, unmodified version.

I think you problem is pretty common in PHP Web applications, where you may have to extract a complete Web application, and then add a configuration file to it.

You can achieve what you need in several different ways:

  • Set up a separate location for the template-based file outside the remote directory. For instance, in PHP applications, I like to change the configuration file to require another configuration file outside the main hierarchy. Fringe benefit: even if the server is misconfigured, items like the database password are still inaccessible through the Web site. However, this would require a modification of the code in your remote directory - you may or may not have control over it.

  • Work with a staging directory. Put the remote_directory into something like /var/www/staging/myapp and the config file into /var/www/staging/config . Then use a script resource to put them all together in the end. The script should have action :nothing, and be triggered by a notification from both your remote directory and your config template.

  • A variation of the previous suggestion: instead of using a remote_directory, tar up the whole directory and use remote_file to download the tarball, then extract it in the script. This works particularly well when you are working with something that may already exist as a tarball to begin with, such as third party webapps.

Kevin Keane
The NetTech
http://www.4nettech.com
Our values: Privacy, Liberty, Justice
See https://www.4nettech.com/corp/the-nettech-values.html