Using Data Bags to store hostnames to bootstrap

Hi everyone,

I try to create a cookbook to bootstrap a bunch of new clients.

My idea is that I could use a linux node with ChefDK to bootstap new clients via knife.
All Hostnames will be stored in a DataBag.

I created a DataBag called ‘Hostnames’ with 2 Items ‘Windows’ and ‘Linux’ and I add the following JSON code for each system:

{
“hostname”:“Systemname”{
“fqdn”:“Systemname.domain”,
“ip”:“xxx.xxx.xxx.xxx”,
“user”:“Administrator”,
“password”:“xxxxxxx”}

}

Is this a way to do this?
How can I get access to this Sublayer in the Databag?

I’d probably start by looking into accessing a data bag from chef-provisioning.

Alternatively you could write a knife exec script: https://docs.chef.io/knife_exec.html. There’s an example of accessing data bags in such a script here: https://www.coveros.com/chef-knife-script-for-encrypting-a-file-a-data-bag/ Then you could loop that data into the bootstrap class? It’d be rather custom, of course.

I’m definitely recommend using ansible for bootstrap purpose. Something like this