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:
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
See hab plan init for more information on how to use this subcommand.
The basic structure of a plan is shown below:
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.
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:
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_versionto your plan file
- Use the
Set-PkgVersionhelper functions to compute
The following shows how to set
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.