Skip to content

Commit

Permalink
Remove execution callback
Browse files Browse the repository at this point in the history
  • Loading branch information
clementblaise committed Jan 21, 2021
1 parent 0a7bc0c commit 637a6ae
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions internal/execution/exec.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
package execution

import (
"bytes"
"fmt"
ansibler "github.com/apenella/go-ansible"
"github.com/apenella/go-ansible/stdoutcallback/results"
"github.com/ca-gip/dploy/internal/ansible"
"strings"
)

func Exec(command ansible.Command) {
var err error
res := &results.AnsiblePlaybookJSONResults{}
buff := new(bytes.Buffer)

func Exec(command ansible.Command) (err error) {
for _, playbook := range MakeCommands(command) {
ansibler.AnsibleForceColor()
err = playbook.Run()
if err != nil {
fmt.Println(err.Error())
return
}

res, err = results.JSONParse(buff.Bytes())

if err != nil {
fmt.Printf("there is an error %s", err)
}

fmt.Println(res.String())
}
return
}

func MakeCommands(command ansible.Command) (commands []ansibler.AnsiblePlaybookCmd) {
for _, inventory := range command.Inventory {
ansiblePlaybookOptions := &ansibler.AnsiblePlaybookOptions{
Inventory: inventory.AbsolutePath,
Inventory: inventory.RelativePath(),
Limit: strings.Join(command.Limit, ","),
Tags: strings.Join(command.Tags, ","),
VaultPasswordFile: command.VaultPasswordFile,
Expand Down

0 comments on commit 637a6ae

Please sign in to comment.