All plans must have a
plan.ps1 at the root of the plan context. They may even include both if a package is targeting both Windows and Linux platforms. This file will be used by the
hab-plan-build command to build your package. To create a plan, do the following:
If you haven’t done so already, download the
habCLI and install it per the instructions on the download page.
hab cli setupand follow the instructions in the setup script.
The easiest way to create a plan is to use the
hab plan initsubcommand. This subcommand will create a directory, known as the plan context, that contains your plan file and any runtime hooks and/or templated configuration data.
hab plan initas part of your project repo, navigate to the root of your project repo and run
hab plan init. It will create a new
habitatsub-directory with a plan.sh (or plan.ps1 on Windows) based on the name of the parent directory, and include a
default.tomlfile as well as
hooksdirectories for you to populate as needed. For example:
cd /path/to/<reponame> hab plan init
will result in a new
habitatdirectory located at
/path/to/<reponame>/habitat. A plan file will be created and the
pkg_namevariable will be set to <reponame>. Also, any environment variables that you have previously set (such as
HAB_ORIGIN) will be used to populate the respective
If you want to auto-populate more of the
pkg_*variables, you also have the option of setting them when calling
hab plan init, as shown in the following example:
env pkg_svc_user=someuser pkg_deps="(core/make core/coreutils)" \ pkg_license="('MIT' 'Apache-2.0')" pkg_bin_dirs="(bin sbin)" \ pkg_version=1.0.0 pkg_description="foo" pkg_maintainer="you" \ hab plan init yourplan
See hab plan init for more information on how to use this subcommand.
Now that you have stubbed out your plan file in your plan context, open it and begin modifying it to suit your needs.
When writing a plan, it’s important to understand that you are defining both how the package is built and the actions Chef Habitat will take when the Supervisor starts and manages the child processes in the package. The following sections explain what you need to do for each phase.
Was this page helpful?