Le 2015-09-23 12:09, Andrew Hodgson a écrit :
Tensibai wrote:
Le 2015-09-22 17:27, Andrew Hodgson a écrit :
Hi,
Just wondering if there is any tutorial out there that goes through modifying Windows .net .config files using Chef whereby the config file is tokenised in the following way:
I want a range of tokens which are unique across the different environments and can be used across apps, and the system will replace the relevant values with the actual values. I have used DSC XTokenize module to do similar in the past, but I >>want to see if I can do it in Chef, possibly using data bags to store the information.
[...]
If they are standard text files, templates[1] are the way to go, I would set the attributes in a chef-vault[2] (to keep the password encrypted on the chef-server side) and named the databag item per the environment.
I did look into templates quite a bit, but wanted a more simple token
replacement strategy rather than relying on a more complex Erubis
structure. I went back to using DSC tokenization in the end using the
xTokenize module.
Thanks for confirming I was looking in the right direction though.
This one (with no clue from where comes the tokens... so hard to really
compare)
Vs a template named Web.config.erb
For a template resource being:
template "path/to/Web.config" do
source "Web.config.erb"
variables( :params => data_bag_item('AppSqlInfo',node.chef_environment
)
end
And a databag 'AppSqlInfo' with an item for each environment containing
a hash like this:
{ :AppDBServer => "Server",
:AppDatabase => "DbName",
:AppDBUserId => "User",
:AppDBPassword => "password
}
What do you find complex there ?
From my window the templates structure is nearly the same (<%= var %>
instead of var), and according to the doc I read on xTokenize,
you'll have to build the hash file or to distribute one according to the
environment too...
I would really like to get your feedback on what you find more complex
in this approach than the xTokenize one