Create Your Plan

At the center of Chef Habitat packaging is the plan. This is a directory comprised of Powershell scripts and optional configuration files that define how you download, configure, make, install, and manage the lifecycle of the software in the package. When writing a plan, it's important to understand that you are defining both how the package is built and how the Chef Habitat service will behave when the Supervisor starts and manages the child process in the package.

To create your plan, navigate to the root of your project repo and run the following:

PS C:\contosouniversity> hab plan init

Using hab plan init will result in a new directory located at C:\contosouniversity\habitat on your workstation. A plan.ps1 file will be created and the $pkg_name variable in it will be set to the name of the parent directory. Also, any environment variables that you have previously set (such as HAB_ORIGIN) will be used to populate the respective $pkg_* variables.

See hab plan init for more information on how to use this subcommand.

The basic structure of a plan is shown below:

PS C:\contosouniversity> tree habitat /F
| default.toml
| plan.ps1
├── config
└── hooks

Note: The plan file is the only required file to create a package. Configuration files, runtime hooks, and other source files are optional. For more information on creating plans, see the Writing plans section of the reference documentation.

The plan.ps1 file generated by hab plan init includes commented lines for all of the possible settings one could add to a plan. Go ahead and delete all but the first five lines of the plan now and we will fill in the rest of the content as we complete this guide. So at this point your plan should look like:

$pkg_maintainer="The Chef Habitat Maintainers <>"


Every package needs a version number to use as part of its package identification. The hab plan init subcommand creates a version for you, but in general, you have two options for adding versioning:

  • Explicitly add pkg_version to your plan file
  • Use the Set-PkgVersion helper functions to compute pkg_version

The following shows how to set pkg_version:


See Basic settings and Utility functions for more information on these versioning options.

The rest of the steps in this guide will show you how to customize your plan, connect to a SQL Server database, and test your package.

Next: Define Dependencies