Skip to content

Commit

Permalink
Merge pull request #17403 from rwc/hab-provisioner-updates
Browse files Browse the repository at this point in the history
[provisioner-habitat] Fix package channel honoring and documentation
  • Loading branch information
jbardin committed Apr 4, 2018
2 parents f51879b + bbd3d7f commit c1edaad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
25 changes: 20 additions & 5 deletions builtin/provisioners/habitat/resource_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func Provisioner() terraform.ResourceProvisioner {
Optional: true,
},
"channel": &schema.Schema{

Type: schema.TypeString,
Optional: true,
},
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions website/docs/provisioners/habitat.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down

0 comments on commit c1edaad

Please sign in to comment.