0
0
mirror of https://github.com/thegeeklab/wp-ansible.git synced 2024-11-22 10:00:38 +00:00

Merge pull request #32 from wbh1/update/vault-syntax-check

Process vault flags prior to syntax check flag
This commit is contained in:
Thomas Boerger 2020-05-15 00:27:58 +02:00 committed by GitHub
commit 57e6895228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,14 +245,20 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
inventory, inventory,
} }
if p.Config.SyntaxCheck { if len(p.Config.ModulePath) > 0 {
args = append(args, "--syntax-check") args = append(args, "--module-path", strings.Join(p.Config.ModulePath, ":"))
args = append(args, p.Config.Playbooks...) }
return exec.Command( if p.Config.VaultID != "" {
"ansible-playbook", args = append(args, "--vault-id", p.Config.VaultID)
args..., }
)
if p.Config.VaultPasswordFile != "" {
args = append(args, "--vault-password-file", p.Config.VaultPasswordFile)
}
for _, v := range p.Config.ExtraVars {
args = append(args, "--extra-vars", v)
} }
if p.Config.ListHosts { if p.Config.ListHosts {
@ -265,8 +271,14 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
) )
} }
for _, v := range p.Config.ExtraVars { if p.Config.SyntaxCheck {
args = append(args, "--extra-vars", v) args = append(args, "--syntax-check")
args = append(args, p.Config.Playbooks...)
return exec.Command(
"ansible-playbook",
args...,
)
} }
if p.Config.Check { if p.Config.Check {
@ -301,10 +313,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
args = append(args, "--list-tasks") args = append(args, "--list-tasks")
} }
if len(p.Config.ModulePath) > 0 {
args = append(args, "--module-path", strings.Join(p.Config.ModulePath, ":"))
}
if p.Config.SkipTags != "" { if p.Config.SkipTags != "" {
args = append(args, "--skip-tags", p.Config.SkipTags) args = append(args, "--skip-tags", p.Config.SkipTags)
} }
@ -317,14 +325,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
args = append(args, "--tags", p.Config.Tags) args = append(args, "--tags", p.Config.Tags)
} }
if p.Config.VaultID != "" {
args = append(args, "--vault-id", p.Config.VaultID)
}
if p.Config.VaultPasswordFile != "" {
args = append(args, "--vault-password-file", p.Config.VaultPasswordFile)
}
if p.Config.PrivateKeyFile != "" { if p.Config.PrivateKeyFile != "" {
args = append(args, "--private-key", p.Config.PrivateKeyFile) args = append(args, "--private-key", p.Config.PrivateKeyFile)
} }