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:
<connectionStrings> <add name="MyConnectionString" connectionString="Data Source=__AppDBServer__;Initial Catalog=__AppDatabase__;User ID=__AppDBUserID__;Password=__AppDBPassword__" providerName="System.Data.SqlClient" /> </connectionStrings>
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.
Like I say I feel I am possibly missing something as there must be a tutorial on it somewhere but not found anything specific, hopefully you guys can prove me wrong!
Thanks, Andrew.
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.
This need some documented steps to load the databag item and pass it to the template resource to render the file according to your needs.Maybe the dsc_resource[3] or dsc_script[4] could be a way to go too, but as I'm not using them I can't really tell.
[1] https://docs.chef.io/resource_template.html
[2] https://github.com/Nordstrom/chef-vault
[3] https://docs.chef.io/resource_dsc_resource.html
[4] https://docs.chef.io/resource_dsc_script.html
Hope this helps.
|