Hi,
I'm still really new with Chef and kind of struggling with some of the concepts and tools, but I currently have a test/experimental cookbook recipe that does dcpromo on a Windows server, i.e., it turns the Windows server into a domain controller.
This recipe uses information from a databag to get the domain name (and the netbios name) and the admin password from a databag.
The data in databag currently looks like:
{
"id": "main",
"domain_name": "whatever.com",
"domain_netbios_name": "whatever",
"admin_password": "Pxxxxx"
}
For a test environment I'm trying to setup, I actually need to AD-enable several domain controllers, so I've been trying to think of how to extend what I've done with Chef thus far, so that I could have one cookbook/recipe that would be able to do that.
I'm thinking that maybe I could have information for multiple domains in the databag, something like:
{
{
"id": "main",
"domain_name": "whatever.com",
"domain_netbios_name": "whatever",
"admin_password": "Pxxxxx"
},
{
"id": "whatever1",
"domain_name": "whatever1.com",
"domain_netbios_name": "whatever1",
"admin_password": "Pxxxxx"
},
{
"id": "whatever2",
"domain_name": "whatever2.com",
"domain_netbios_name": "whatever2",
"admin_password": "Pxxxxx"
}
}
and then, in the recipe, load the databag/item using ohai 'node['hostname']', instead of the hard-coded 'main'.
In other words, instead of having:
begin
dcpromote = Chef::DataBagItem.load('dcpromote', 'main')
rescue
Chef::Log.fatal("Could not find the 'main' item in the 'dcpromote' data bag - Raising fatal error!!")
raise
end
I'd have:
begin
dcpromote = Chef::DataBagItem.load('dcpromote', node['hostname'])
rescue
Chef::Log.fatal("Could not find the 'main' item in the 'dcpromote' data bag - Raising fatal error!!")
raise
end
Is that the correct way to get the (short) hostname from ohai? And, overall, would the approach that I've described above work?
Is there maybe a better way to do this (using Chef)? At one point, I was thinking of using roles, but then it seemed like I'd end up having to create one role for each of the specific domain controller nodes?
Thanks,
Jim
425.341.3619 – " style="color:rgb(17,85,204)" target="_blank"> my: Linkedin Twitter
CHEF | TM |
Archive powered by MHonArc 2.6.16.