From 5d47351d1004c65beb13293b8506e4972e602cfd Mon Sep 17 00:00:00 2001 From: Will Hegedus Date: Wed, 8 Apr 2020 14:26:07 -0400 Subject: [PATCH 1/2] Process vault flags prior to syntax check flag --- plugin.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugin.go b/plugin.go index a0630ed..8191e5c 100644 --- a/plugin.go +++ b/plugin.go @@ -245,8 +245,8 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { inventory, } - if p.Config.SyntaxCheck { - args = append(args, "--syntax-check") + if p.Config.ListHosts { + args = append(args, "--list-hosts") args = append(args, p.Config.Playbooks...) return exec.Command( @@ -255,8 +255,16 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { ) } - if p.Config.ListHosts { - args = append(args, "--list-hosts") + 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.SyntaxCheck { + args = append(args, "--syntax-check") args = append(args, p.Config.Playbooks...) return exec.Command( @@ -317,14 +325,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { 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 != "" { args = append(args, "--private-key", p.Config.PrivateKeyFile) } From 9ad55755274b35acd6409fc8e47da6407f176cb5 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Fri, 15 May 2020 00:03:35 +0200 Subject: [PATCH 2/2] Move all important flags to the top --- plugin.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugin.go b/plugin.go index 8191e5c..0c52eac 100644 --- a/plugin.go +++ b/plugin.go @@ -245,6 +245,22 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { inventory, } + if len(p.Config.ModulePath) > 0 { + args = append(args, "--module-path", strings.Join(p.Config.ModulePath, ":")) + } + + 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) + } + + 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...) @@ -255,14 +271,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { ) } - 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.SyntaxCheck { args = append(args, "--syntax-check") args = append(args, p.Config.Playbooks...) @@ -273,10 +281,6 @@ func (p *Plugin) ansibleCommand(inventory string) *exec.Cmd { ) } - for _, v := range p.Config.ExtraVars { - args = append(args, "--extra-vars", v) - } - if p.Config.Check { args = append(args, "--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) }