0
0
mirror of https://github.com/thegeeklab/wp-ansible.git synced 2024-11-25 09:00:39 +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,
}
if p.Config.ListHosts {
args = append(args, "--list-hosts")
args = append(args, p.Config.Playbooks...)
return exec.Command(
"ansible-playbook",
args...,
)
if len(p.Config.ModulePath) > 0 {
args = append(args, "--module-path", strings.Join(p.Config.ModulePath, ":"))
}
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)
}
if p.Config.SyntaxCheck {
args = append(args, "--syntax-check")
for _, v := range p.Config.ExtraVars {
args = append(args, "--extra-vars", v)
}
if p.Config.ListHosts {
args = append(args, "--list-hosts")
args = append(args, p.Config.Playbooks...)
return exec.Command(
@ -273,8 +271,14 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
)
}
for _, v := range p.Config.ExtraVars {
args = append(args, "--extra-vars", v)
if p.Config.SyntaxCheck {
args = append(args, "--syntax-check")
args = append(args, p.Config.Playbooks...)
return exec.Command(
"ansible-playbook",
args...,
)
}
if p.Config.Check {
@ -309,10 +313,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd {
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 != "" {
args = append(args, "--skip-tags", p.Config.SkipTags)
}