0

Using a simple template block, is there a way to copy all template files in a templates/default/SubDir/ (templates/default/SubDir/*) to a single location (/tmp/)? Here is an example block:

template '/tmp/...' do
    source 'default/SubDir/...'
    owner node['attribute']['os_user']
    group node['attribute']['os_group']
    mode '0755'
end

EDIT: these are all xml files and I assume that I would not be adding the .erb extension to the template files, as that would require me to mention each template file name so that i can revert them back to .xml (as apposed to recursively copying the templates to the server).

NOTE: If this is not supported, then is there any recommended approach requiring strait ruby code?


EDIT: I am going to try making an aray of template files and see if that would work if I were to copy the entire array to the node.

aphexlog
  • 1,503
  • 3
  • 16
  • 43

2 Answers2

1

I solved this problem by creating an array with the objects(templates) I needed to copy to the server.. it looks something like this:

auth_schemas = ['file1.xml','file2.xml','file3.xml','file4.xml','file5.xml','file6.xml','file7.xml','file8.xml','file9.xml','file10.xml']
        auth_schemas.each do |schemaFile|
          template "/tmp/#{schemaFile}" do
            source "path/to/SubDir/#{schemaFile}"
            owner node['attribute']['os_user']
            group node['attribute']['os_group']
            mode '0755'
          end
        end

Worked Like a charm!

aphexlog
  • 1,503
  • 3
  • 16
  • 43
0

No, that is not supported. Some additional characters because SO forces me to.

coderanger
  • 52,400
  • 4
  • 52
  • 75