Skip to content

Instantly share code, notes, and snippets.

@mattray
Created June 8, 2017 06:35
Show Gist options
  • Select an option

  • Save mattray/e6d05dce0c2b7f176d665b536a719348 to your computer and use it in GitHub Desktop.

Select an option

Save mattray/e6d05dce0c2b7f176d665b536a719348 to your computer and use it in GitHub Desktop.

Bulk Node Bootstapping

Spiceweasel generates Chef knife commands from a JSON or YAML file. It provides a condensed format to make it easier batch load Chef infrastructure. From the Mass Node Bootstrapping doc "workstation-to-node-to-server bootstrap won’t work", Spiceweasel doesn't solve this it simply scripts knife calls and uses the "parallel" command to batch them up. It does break down the steps to bootstrapping that infrastructure and provides some internal validation that nodes are not trying to use unlisted cookbooks, roles and other Chef primitives. It also provides for deletion of the listed content.

Spiceweasel development has been dormant for over 2 years, but it has an extensive test suite. It needs to be updated for Chef 12/13, updated for Ruby 2.3 and made compatible with the latest ChefDK.

Bootstrapping Clients

Spiceweasel does not currently support "knife client" commands but this would be straightforward to add. Syntax like:

clients:
- serverA:
- serverB serverC:
    file: {{name}}-key

would produce

knife client create serverA
knife client create serverB --file serverB-key
knife client create serverC --file serverC-key

Validation

To ensure clients have all been successfully created will require validating that the content generated by Spiceweasel exists on the Chef Server. This was a frequent request that would be relatively easy to validate via parsing knife output or directly against the API.

Separating bootstrap from first run

Spiceweasel currently takes a run_list as an argument while creating nodes. If there is a desire to separate the initial bootstrap from application of that run_list, a flag could be introduced to turn

nodes:
- serverA:
    run_list: role[base],role[database]

into

knife bootstrap serverA
knife node run_list set serverA 'role[base],role[database]'

and the exist --chef-client flag could be used to separately generate.

knife ssh 'name:serverA' chef-client'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment