Merge pull request #17403 from rwc/hab-provisioner-updates

[provisioner-habitat] Fix package channel honoring and documentation
This commit is contained in:
James Bardin 2018-04-04 16:55:24 -04:00 committed by GitHub
commit c1edaadc7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -179,6 +179,7 @@ func Provisioner() terraform.ResourceProvisioner {
Optional: true, Optional: true,
}, },
"channel": &schema.Schema{ "channel": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
@ -626,22 +627,36 @@ func (p *provisioner) createHabUser(o terraform.UIOutput, comm communicator.Comm
return nil 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 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 { 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 { } 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 != "" { if p.BuilderAuthToken != "" {
command = fmt.Sprintf("env HAB_AUTH_TOKEN=%s %s", p.BuilderAuthToken, command) 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 return err
} }
if err := p.uploadUserTOML(o, comm, service); err != nil { if err := p.uploadUserTOML(o, comm, service); err != nil {
return err return err
} }

View File

@ -70,9 +70,9 @@ There are 2 configuration levels, `supervisor` and `service`. Configuration pla
```hcl ```hcl
bind { bind {
Alias = "backend" alias = "backend"
Service = "nginx" service = "nginx"
Group = "default" group = "default"
} }
``` ```
* `topology (string)` - (Optional) Topology to start service in. Possible values `standalone` or `leader`. (Defaults to `standalone`) * `topology (string)` - (Optional) Topology to start service in. Possible values `standalone` or `leader`. (Defaults to `standalone`)