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

Move all important flags to the top

This commit is contained in:
Thomas Boerger 2020-05-15 00:03:35 +02:00 committed by GitHub
parent 5d47351d10
commit 9ad5575527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,14 +245,8 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
inventory, inventory,
} }
if p.Config.ListHosts { if len(p.Config.ModulePath) > 0 {
args = append(args, "--list-hosts") args = append(args, "--module-path", strings.Join(p.Config.ModulePath, ":"))
args = append(args, p.Config.Playbooks...)
return exec.Command(
"ansible-playbook",
args...,
)
} }
if p.Config.VaultID != "" { if p.Config.VaultID != "" {
@ -263,8 +257,12 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
args = append(args, "--vault-password-file", p.Config.VaultPasswordFile) args = append(args, "--vault-password-file", p.Config.VaultPasswordFile)
} }
if p.Config.SyntaxCheck { for _, v := range p.Config.ExtraVars {
args = append(args, "--syntax-check") args = append(args, "--extra-vars", v)
}
if p.Config.ListHosts {
args = append(args, "--list-hosts")
args = append(args, p.Config.Playbooks...) args = append(args, p.Config.Playbooks...)
return exec.Command( return exec.Command(
@ -273,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 {
@ -309,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)
} }