1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use current cookbook template dir to copy all templates recursively in a loop with chef

Discussion in 'Main Forum' started by gansbrest, Oct 8, 2018.

  1. gansbrest

    gansbrest Guest

    I'm trying to figure out how can I construct the path to templates (or files, since it works the same way) folder, then I could read it and use template resource in the loop, so each template file could trigger notification on change.

    I can't use remote_directory because I want to notify services only if template changes.

    I also would like to avoid manual template specification, since there could be many files inside those dirs. Plus it would allow us to change just configs in the templates folder without touching recipe.

    The main problem is those subdirectories like default, host, host-version and the logic chef goes through to determine correct templates folder. I was thinking maybe there is a method in one of the Chef classes I could call from my custom cookbook to get to the starting point for my logic (loop).

    It should be something like this I think:

    entry_point = CHEF::...getEntryPointDir

    .each do

    template fname do


    I would appreciate any help!

    Login To add answer/comment

Share This Page