Skip to content

Chef LWRP for parsing templates recursively in a directory and automatically populating your variables hash from a hash attribute

Notifications You must be signed in to change notification settings

phutchins/naruto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naruto

Chef LWRP for parsing templates recursively in a directory and automatically populating your variables hash from a hash attribute

Depends

You must add naruto to your metadata.rb

Attributes

Populate an attribute with a hash to use as your variable keys (names) and values

You can add common values to get parsed into all templates

node.set['mycookbook']['myapp']['db_host'] = 'host1'
node.set['mycookbook']['myapp']['db_user'] = 'user1'
node.set['mycookbook']['myapp']['db_pass'] = 'greatpassword'
node.set['mycookbook']['myapp']['db_name'] = 'awesomedb'

Add app or template specific values to only be parsed into certain templates

node.set['mycookbook']['common']['log_dir'] = '/var/log'
node.set['mycookbook']['common']['tmp_dir'] = '/tmp'    

Create merged hash of attributes that we need to parse into the templates

myapp_variables = {}
myapp_variables = node['mycookbook']['common'].to_hash.merge(node['mycookbook']['myapp'].to_hash)

Resource Usage

naruto_recursive_parse 'myapp_templates' do
  action :create
  base_dir "/opt/myapp"
  variables myapp_variables
  notifies :restart, 'service[myapp]'
end

Optional resource parameters

This allows you to ignore files or patterns matched in a file name. It is a regex and will match your entry anywhere in the file's path or name.

ignore_file ["file.one", "otherfile.two"]

About

Chef LWRP for parsing templates recursively in a directory and automatically populating your variables hash from a hash attribute

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages