Installing Chef Habitat as a service on CentOS7 and configuring Automate data collector with an Effortless package
- Download and run the Habitat installation script
$ curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash
- Accept the Habitat license
$ hab license accept
- Add hab as a user and add to group habitat
$ groupadd hab
$ adduser hab -g hab
- Create systemd service definition by creating the file
/etc/systemd/system/hab-sup.service
with the following contents and replace the values:
<HAB_AUTH_TOKEN>
# define: auth to bldr to bring down pkgs<NAME_OF_APP>
# define<NAME_OF_ENV>
# define<NAME_OF_SITE>
# define<AUTOMATE_REPORTER_HOSTNAME>
# sends app data to applications tab in automate<AUTOMATE_REPORTER_TOKEN>
[Unit]
Description=Habitat Supervisor
[Service]
Environment=HAB_LICENSE=accept-no-persist
Environment=HAB_AUTH_TOKEN=<HAB_AUTH_TOKEN>
ExecStart=/bin/hab run --auto-update --listen-gossip 0.0.0.0:9638 --listen-http 0.0.0.0:9631 --event-stream-application=<NAME_OF_APP> --event-stream-environment=<NAME_OF_ENV> --event-stream-site=<NAME_OF_SITE> --event-stream-url=<AUTOMATE_REPORTER_HOSTNAME>:4222 --event-stream-token=<AUTOMATE_REPORTER_TOKEN>
[Install]
WantedBy=default.target
- Reload daemon, enable, then start service.
$ systemctl daemon-reload
$ systemctl enable hab-sup
$ systemctl start hab-sup
- Now the Habitat Supervisor should be running as a service. You can validate this by running the following command
$ systemctl status hab-sup
You can access the logs
$ journalctl -fu hab-sup
- Now that the Habitat Supervisor is running in the background, we can now load a service.
- namespace (origin) / pkg name
$ hab svc load chef/effortless-audit-baseline
interval = 1800
splay = 1800
splay_first_run = 0
log_level = 'warn'
[chef_license]
acceptance = "undefined"
[automate]
enable = false
server_url = 'https://<automate_url>'
token = '<automate_token>'
user = '<automate_user>'
interval = 300
report_to_stdout = false
chef_license.acceptance = "accept-no-persist"
# Uncomment and replace values to report to Automate.
# # # This can also be applied at runtime via `hab config apply`
[automate]
enable = "true"
server_url = "https://automate.example.com"
token = "x9Gfdw34O534d54ytgdfQlKq4TApDE="