loading...
Cover image for Three quick tips when setting up a new node with Chef Infra!

Three quick tips when setting up a new node with Chef Infra!

sigje profile image Jennifer Davis ・2 min read

I was helping someone this evening with setting up a new node with Chef Infra. I wanted to document this so that if someone else experienced a similar problem, it might be a bit easier to understand what's going on.

Tip 1 Ask for help when you get stuck.

The problem statement was "trying to pass a JSON file to chef-zero for extra attributes." The command in use was chef-client.

Folks might not know the exact terminology in use by a product so it can be hard to figure it out without guidance. Folks with expertise may be able to give you more insight with the right terminology.

To make sure I understood what the person was looking for, I asked clarifying questions. The answers to those questions helped me understand that this was setting up a new instance or bootstrapping. While the chef-client page has helpful information, it isn't as specific and direct as the bootstrapping page.

Tip 2 Don't pass -o and -j both to chef-client.

-o overrides the run_list, and -j is how you specify a file that includes the recipes and attributes that you want to run. So instead of using both -j and -o, we took the configuration specified after -o and added it to the JSON file.

Tip 3 The JSON file has a particular format that shouldn't look like a standard attribute file.

Within the node attributes file, attributes look like node['resolver']['nameservers']. So this:

{
    "node['resolver']['nameservers']": ["10.0.0.1"],
    "node['search']": "http://sparkle.corp",
    "run_list": ["recipe[resolver]"]
}

is valid JSON and looks close to the appropriate configuration within the node attributes definitions. It will even successfully be accepted but won't have the expected behavior. No errors will point you to the problem with the JSON file on converge.

Instead, the JSON file should look like this:

{
    "resolver": {
        "nameservers": ["10.0.0.1"],
        "search": "http://sparkle.corp"
    },
    "run_list": ["recipe[resolver]"]
}

That's all for now!

Posted on by:

sigje profile

Jennifer Davis

@sigje

Jennifer is a site reliability engineer, author and public speaker. She founded CoffeeOps, co-wrote Effective DevOps, and organizes devopsdays.

Discussion

markdown guide