diff --git a/builtin/provisioners/habitat/resource_provisioner.go b/builtin/provisioners/habitat/resource_provisioner.go index 6c41fe8ef..26682b339 100644 --- a/builtin/provisioners/habitat/resource_provisioner.go +++ b/builtin/provisioners/habitat/resource_provisioner.go @@ -179,6 +179,7 @@ func Provisioner() terraform.ResourceProvisioner { Optional: true, }, "channel": &schema.Schema{ + Type: schema.TypeString, Optional: true, }, @@ -626,22 +627,36 @@ func (p *provisioner) createHabUser(o terraform.UIOutput, comm communicator.Comm return nil } -func (p *provisioner) startHabService(o terraform.UIOutput, comm communicator.Communicator, service Service) error { +// In the future we'll remove the dedicated install once the synchronous load feature in hab-sup is +// available. Until then we install here to provide output and a noisy failure mechanism because +// if you install with the pkg load, it occurs asynchronously and fails quietly. +func (p *provisioner) installHabPackage(o terraform.UIOutput, comm communicator.Communicator, service Service) error { var command string + options := "" + if service.Channel != "" { + options += fmt.Sprintf(" --channel %s", service.Channel) + } + + if service.URL != "" { + options += fmt.Sprintf(" --url %s", service.URL) + } if p.UseSudo { - command = fmt.Sprintf("env HAB_NONINTERACTIVE=true sudo -E hab pkg install %s", service.Name) + command = fmt.Sprintf("env HAB_NONINTERACTIVE=true sudo -E hab pkg install %s %s", service.Name, options) } else { - command = fmt.Sprintf("env HAB_NONINTERACTIVE=true hab pkg install %s", service.Name) + command = fmt.Sprintf("env HAB_NONINTERACTIVE=true hab pkg install %s %s", service.Name, options) } if p.BuilderAuthToken != "" { command = fmt.Sprintf("env HAB_AUTH_TOKEN=%s %s", p.BuilderAuthToken, command) } + return p.runCommand(o, comm, command) +} - if err := p.runCommand(o, comm, command); err != nil { +func (p *provisioner) startHabService(o terraform.UIOutput, comm communicator.Communicator, service Service) error { + var command string + if err := p.installHabPackage(o, comm, service); err != nil { return err } - if err := p.uploadUserTOML(o, comm, service); err != nil { return err } diff --git a/website/docs/provisioners/habitat.html.markdown b/website/docs/provisioners/habitat.html.markdown index 55ac2232b..f96239b8e 100644 --- a/website/docs/provisioners/habitat.html.markdown +++ b/website/docs/provisioners/habitat.html.markdown @@ -70,9 +70,9 @@ There are 2 configuration levels, `supervisor` and `service`. Configuration pla ```hcl bind { - Alias = "backend" - Service = "nginx" - Group = "default" + alias = "backend" + service = "nginx" + group = "default" } ``` * `topology (string)` - (Optional) Topology to start service in. Possible values `standalone` or `leader`. (Defaults to `standalone`)