Plan Quickstart
All plans must have a plan.sh or 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 according to the instructions on the download page.Run
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.To use
hab plan initas part of your project repo, navigate to the root of your project repo and runhab plan init. It will create a newhabitatsub-directory with aplan.sh(orplan.ps1on Windows) based on the name of the parent directory, and include adefault.tomlfile as well asconfigandhooksdirectories for you to populate as needed. For example:cd /path/to/<reponame> hab plan initwill result in a new
habitatdirectory located at/path/to/<reponame>/habitat. A plan file will be created and thepkg_namevariable will be set to <reponame>. Also, any environment variables that you have previously set (such asHAB_ORIGIN) will be used to populate the respectivepkg_*variables.If you want to auto-populate more of the
pkg_*variables, you also have the option of setting them when callinghab 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 yourplanSee 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.