I am provisioning a Windows Server 2012 Standard Edition (64 bit) and 'Windows Server 2012 Datacenter Edition (64bit) in Softlayer. And as per my project requirement, the additional disks attached to the Windows servers (both SAN and Local) should be formatted. For this I have to develop a chef cookbook which will format the additional disk. How can I do this ? Any documentation which I can refer ?
2 Answers
The answer to any "How do I do X with Chef?" is always the same, how would you do X without Chef? Then go write some code which does that. In this case, go look up how to mount a disk from your SAN, and how to format a Windows disk from the command line. With all that you should be able to write your recipe pretty easily.
The additional disks that you’re trying to format can be accomplished running a post-install script. Using SL API for a Virtual Guest would be: (REST example)
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject
Method: POST
Body:
{
"parameters": [
{
"hostname": "myInstanceName",
"domain": "example.com",
"maxMemory": 4096,
"startCpus": 1,
"blockDevices": [
{
"device": "0",
"diskImage": {
"capacity": 100
}
},
{
"device": "2",
"diskImage": {
"capacity": 25
}
}
],
"localDiskFlag": true
"hourlyBillingFlag": true,
"localDiskFlag": false,
"operatingSystemReferenceCode": "UBUNTU_LATEST",
"datacenter": {
"name": "dal05"
},
"postInstallScriptUri": "https://www.softlayer.com"
}
]
}
Note that the body request’s got the postInstallScriptUri attribute, which is in charge of provide your customized script. You might also review this methods that are going to help you in managing this post install scripts: http://sldn.softlayer.com/reference/services/SoftLayer_Account/getPostProvisioningHooks http://sldn.softlayer.com/reference/services/SoftLayer_Provisioning_Hook
This is the command line in knife-chef to create a server with additional disks and postInstallScript.
knife softlayer server create -H test -D example.com \ --block-storage 0:25,2:100,5:1000 \ # device:GB, device:GB, ...
--network-interface-speed 1000 \
--cores 8 \
--ram 49152 \
--os-code REDHAT_6_64 \
--datacenter ams01 \
--bootstrap-url http://www.softlayer.com/myscript
--node-name random-node-name
Review these links, They are a very good source of information with examples as well. https://sldn.softlayer.com/blog/jarteche/Getting-Started-User-Data-and-Post-Provisioning-Scripts http://bodenr.blogspot.com/2014/04/giving-your-softlayer-servers.html
Finally, You could try this SoftLayer Knife: https://sldn.softlayer.com/blog/matteldridge/Do-More-Less-SoftLayer-Knife-Chef