Skip to content

Commit

Permalink
(fixup) Check bolt result status
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Dec 12, 2018
1 parent e4992e0 commit c09ecad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions builtin/provisioners/puppet/resource_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ func (p *provisioner) writeCSRAttributes(attrs *csrAttributes) (rerr error) {
}

func (p *provisioner) generateAutosignToken(certname string) (string, error) {
task := "autosign::generate_token"

masterConnInfo := map[string]string{
"type": "ssh",
"host": p.Server,
Expand All @@ -251,13 +253,17 @@ func (p *provisioner) generateAutosignToken(certname string) (string, error) {
result, err := bolt.Task(
masterConnInfo,
p.ServerUser != "root",
"autosign::generate_token",
task,
map[string]string{"certname": certname},
)
if err != nil {
return "", err
}
// TODO check error state in JSON

if result.Items[0].Status != "success" {
return "", fmt.Errorf("Bolt %s failed on %s: %v", task, result.Items[0].Node, result.Items[0].Result["_error"])
}

return result.Items[0].Result["_output"], nil
}

Expand All @@ -269,7 +275,7 @@ func (p *provisioner) installPuppetAgentOpenSource() error {
nil,
)

if err != nil {
if err != nil || result.Items[0].Status != "success" {
return fmt.Errorf("puppet_agent::install failed: %s\n%+v", err, result)
}

Expand Down

0 comments on commit c09ecad

Please sign in to comment.