Skip to content

Commit

Permalink
Remove fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
clementblaise committed Jul 20, 2021
1 parent 95fda79 commit 9feb4c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func exec(cmd *cobra.Command, args []string, path string) {
options.AnsibleForceColor()
err := adhoc.Run(context.TODO())
if err != nil {
log.Fatal(err)
log.Error(err)
}
}

Expand Down
15 changes: 14 additions & 1 deletion cmd/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package cmd

import (
"context"
"github.com/apenella/go-ansible/pkg/execute"
"github.com/apenella/go-ansible/pkg/options"
"github.com/apenella/go-ansible/pkg/playbook"
"github.com/apenella/go-ansible/pkg/stdoutcallback/results"
"github.com/ca-gip/dploy/internal/ansible"
"github.com/ca-gip/dploy/internal/utils"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -98,6 +100,8 @@ func play(cmd *cobra.Command, args []string, path string) {
limit, _ := cmd.Flags().GetStringSlice("limit")
vaultPassFile, _ := cmd.Flags().GetString("vault-password-file")

summary := make(map[string]bool, len(inventories))

// Execute ansible for each inventory (sequential)
for _, inventory := range inventories {
ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{
Expand All @@ -110,12 +114,21 @@ func play(cmd *cobra.Command, args []string, path string) {
play := playbook.AnsiblePlaybookCmd{
Playbooks: []string{play.RelativePath()},
Options: ansiblePlaybookOptions,
Exec: execute.NewDefaultExecute(
execute.WithTransformers(
results.Prepend(inventory.RelativePath()),
)),
}

options.AnsibleForceColor()
err := play.Run(context.TODO())
if err != nil {
log.Fatal(err)
log.Error(err)
summary[inventory.RelativePath()] = false
} else {
summary[inventory.RelativePath()] = true
}
}

log.Info(summary)
}

0 comments on commit 9feb4c0

Please sign in to comment.