mirror of
https://github.com/thegeeklab/wp-ansible.git
synced 2024-11-22 10:00:38 +00:00
Add glob support for playbook files
This commit is contained in:
parent
a5df060f46
commit
6fefddaa48
24
plugin.go
24
plugin.go
@ -5,6 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (p *Plugin) Exec() error {
|
func (p *Plugin) Exec() error {
|
||||||
|
if err := p.playbooks(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := p.ansibleConfig(); err != nil {
|
if err := p.ansibleConfig(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -167,6 +172,25 @@ func (p *Plugin) vaultPass() error {
|
|||||||
return nil
|
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 {
|
func (p *Plugin) versionCommand() *exec.Cmd {
|
||||||
args := []string{
|
args := []string{
|
||||||
"--version",
|
"--version",
|
||||||
|
Loading…
Reference in New Issue
Block a user