Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"

Expand Down Expand Up @@ -64,6 +65,10 @@ type (
)

func (p *Plugin) Exec() error {
if err := p.playbooks(); err != nil {
return err
}

if err := p.ansibleConfig(); err != nil {
return err
}
Expand Down Expand Up @@ -167,6 +172,25 @@ func (p *Plugin) vaultPass() error {
return nil
}

func (p *Plugin) playbooks() error {
var playbooks []string
for _, p := range p.Config.Playbooks {
files, err := filepath.Glob(p)
// can there be a invalid glob pattern that still is a valid file name?
// just add it back to the list and let ansible return error out instead.
if err != nil {
playbooks = append(playbooks, p)
continue
}
playbooks = append(playbooks, files...)
}
if len(playbooks) == 0 {
return errors.New("failed to find playbook files")
}
p.Config.Playbooks = playbooks
return nil
}

func (p *Plugin) versionCommand() *exec.Cmd {
args := []string{
"--version",
Expand Down