Skip to main content

Service Template Data

The following settings can be used during a Chef Habitat service’s lifecycle. This means that you can use these settings in any of the plan hooks, such as init, or run, and also in any templatized configuration file for your application or service.

These configuration settings are referenced using the Handlebars.js version of Mustache-style tags.

sys

System information

PropertyTypeDescription
ctl_gateway_ipstringListening address for Supervisor’s Control Gateway.
ctl_gateway_portintegerListening port for Supervisor’s Control Gateway.
gossip_ipstringListening address for Supervisor’s gossip connection.
gossip_portintegerListening port for Supervisor’s gossip connection.
hostnamestringThe hostname of the running service.
http_gateway_ipstringListening address for Supervisor’s HTTP gateway.
http_gateway_portintegerListening port for Supervisor’s HTTP gateway.
ipstringThe IP address of the running service.
member_idstringThe member’s Supervisor ID, e.g., 3d1e73ff19464a27aea3cdc5c2243f74
permanentbooleanSet to true if a Supervisor is being used as a permanent peer, to increase Ring network traffic stability.
versionstringVersion of the Habitat Supervisor, e.g., 0.54.0/20180221023448

pkg

Details about the package currently running the service

PropertyTypeDescription
identstringThe fully-qualified identifier of the running package, e.g., core/redis/3.2.4/20170514150022
originstringThe origin of the Habitat package
namestringThe name of the Habitat package
versionstringThe version of the Habitat package
releasestringThe release of the Habitat package
depsarrayAn array of runtime dependencies for your package based on the pkg_deps setting in a plan
envobjectThe runtime environment of your package, mirroring the contents of the RUNTIME_ENVIRONMENT metadata file. The PATH variable is set, containing all dependencies of your package, as well as any other runtime environment variables that have been set by the package. Individual variables can be accessed directly, like {{pkg.env.PATH}} (the keys are case sensitive).
exposesarrayThe array of ports to expose for an application or service. This value is pulled from the pkg_exposes setting in a plan.
exportsobjectA map of export key to internal configuration value key (i.e., the contents of pkg_exports in your plan). The key is what external services consume. The value is a key in your default.toml file that corresponds to the data being exported.
pathstringThe location where the package is installed locally, e.g., /hab/pkgs/core/redis/3.2.4/20170514150022. Note that this is not a PATH environment variable; for that, please see the env key above.
svc_pathstringThe root location of the source files for the Habitat service, e.g., /hab/svc/redis.
svc_config_pathstringThe location of any templated configuration files for the Habitat service, e.g., /hab/svc/redis/config.
svc_data_pathstringThe location of any data files for the Habitat service, e.g., /hab/svc/redis/data.
svc_files_pathstringThe location of any gossiped configuration files for the Habitat service, e.g., /hab/svc/redis/files.
svc_static_pathstringThe location of any static content for the Habitat service, e.g., /hab/svc/redis/static.
svc_var_pathstringThe location of any variable state data for the Habitat service, e.g., /hab/svc/redis/var.
svc_pid_filestringThe location of the Habitat service pid file, e.g., /hab/svc/redis/PID.
svc_runstringThe location of the rendered run hook for the Habitat service, e.g., /hab/svc/redis/run.
svc_userstringThe value of pkg_svc_user specified in a plan.
svc_groupstringThe value of pkg_svc_group specified in a plan.

cfg

These are settings defined in your templatized configuration file. The values for those settings are pulled from the default.toml file included in your package.

svc

Information about the current service’s service group

PropertyTypeDescription
servicestringThe name of the service. If the service is running from the package core/redis, the value will be redis.
groupstringThe group portion of the service’s complete group name. In the group name redis.default, the group’s value is default.
orgstringThe organization portion of a service group specification. Unused at this time.
election_is_runningbooleanWhether a leader election is currently running for this service
election_is_no_quorumbooleanWhether there is quorum for a leader election for this service
election_is_finishedbooleanWhether a leader election for this service has finished
update_election_is_runningbooleanWhether an update leader election is currently running for this service
update_election_is_no_quorumbooleanWhether there is quorum for an update leader election for this service
update_election_is_finishedbooleanWhether an update leader election for this service has finished
mesvc_memberAn object that provides information about the service running on the local Supervisor
firstsvc_memberThe first member of this service group, or the leader, if running in a leader topology
membersarrayAll active members (alive and suspect) of the service group, across the entire ring. As of 0.56.0, does not include departed or confirmed members
leadersvc_memberThe current leader of the service group, if any (null otherwise)
update_leadersvc_memberThe current update_leader of the service group, if any (null otherwise)

bind

Exposes information about the service groups this service is bound to. Each key is the name of a bind, while each value is one of the objects described below

PropertyTypeDescription
firstsvc_memberThe first member of this service group. If the group is running in a leader topology, this will also be the leader.
leadersvc_memberThe current leader of this service group, if running in a leader topology
membersarrayAll active members (alive and suspect) of the service group, across the entire ring. As of 0.56.0, does not include departed or confirmed members

Reference Objects

Some of the template expressions referenced above return objects of a specific shape; for example, the svc.me and svc.first expressions return “service member” objects, and the pkg property of a service member returns a “package identifier” object. These are defined below.

package_identifier

A Habitat package identifier, split apart into its constituent components

PropertyTypeDescription
originstringThe origin of the Habitat package
namestringThe name of the Habitat package
versionstringThe version of the Habitat package
releasestringThe release of the Habitat package

svc_member

Represents a member of a service group

PropertyTypeDescription
member_idstringthe member’s Supervisor id, e.g., 3d1e73ff19464a27aea3cdc5c2243f74
alivebooleanWhether this member is considered alive and connected to the ring, from a network perspective.
suspectbooleanWhether this member is considered “suspect”, or possibly unreachable, from a network perspective.
confirmedbooleanWhether this member is confirmed dead / unreachable, from a network perspective.
departedbooleanWhether this member has been departed from the ring (i.e., permanently gone, never to return).
election_is_runningbooleanWhether a leader election is currently running for this service
election_is_no_quorumbooleanWhether there is quorum for a leader election for this service
election_is_finishedbooleanWhether a leader election for this service has finished
update_election_is_runningbooleanWhether an update leader election is currently running for this service
update_election_is_no_quorumbooleanWhether there is quorum for an update leader election for this service
update_election_is_finishedbooleanWhether an update leader election for this service has finished
leaderbooleanWhether this member is the leader in the service group (only meaningful in a leader topology)
followerbooleanWhether this member is a follower in the service group (only meaningful in a leader topology)
update_leaderbooleanWhether this member is the update leader in the service group (only meaningful in a leader topology)
update_followerbooleanWhether this member is an update follower in the service group (only meaningful in a leader topology)
pkgpackage_identifierThe identifier of the release the member is running
pkg_incarnationintegerIncarnation number associated with this package update
packagestringThe package identifier
sysobjectAn abbreviated version of the top-level {{sys}} object, containing networking information for the member.
cfgobjectThe configuration the member is currently exporting. This is constrained by what is defined in pkg_exports, where the values are replaced with the current values (e.g., taking into account things like user.toml, gossiped configuration values, etc.)
persistentbooleanA misspelling of permanent; indicates whether a member is a permanent peer or not
servicestringThe name of the service. If the service is running from the package core/redis, the value will be redis.
groupstringThe group portion of the service’s complete group name. In the group name redis.default, the group’s value is default.
orgstringThe organization portion of a service group specification. Unused at this time.

Thank you for your feedback!

×









Search Results