From 7cb17f64a6c725993e9c7a083aedfda443ebbb22 Mon Sep 17 00:00:00 2001 From: Larry <34108925+gamethis@users.noreply.github.com> Date: Tue, 25 Aug 2020 08:53:41 -0500 Subject: [PATCH] Added AnsibleSSHExtraArgs --- provisioner/ansible/provisioner.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 1c226fa12..a9bcdd344 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -89,6 +89,8 @@ type Config struct { AnsibleEnvVars []string `mapstructure:"ansible_env_vars"` // The playbook to be run by Ansible. PlaybookFile string `mapstructure:"playbook_file" required:"true"` + // Specifies --ssh-extra-args on command line defaults to -o IdentitiesOnly=yes + AnsibleSSHExtraArgs []string `mapstructure:"ansible_ssh_extra_args"` // The groups into which the Ansible host should // be placed. When unspecified, the host is not associated with any groups. Groups []string `mapstructure:"groups"` @@ -701,7 +703,15 @@ func (p *Provisioner) createCmdArgs(httpAddr, inventory, playbook, privKeyFile s if p.generatedData["ConnType"] == "ssh" && len(privKeyFile) > 0 { // Add ssh extra args to set IdentitiesOnly - args = append(args, "--ssh-extra-args", "'-o IdentitiesOnly=yes'") + if len(p.config.AnsibleSSHExtraArgs) > 0 { + var sshExtraArgs string + for _, sshExtraArg := range p.config.AnsibleSSHExtraArgs { + sshExtraArgs = sshExtraArgs + sshExtraArg + } + args = append(args, "--ssh-extra-args", fmt.Sprintf("'%s'", sshExtraArgs)) + } else { + args = append(args, "--ssh-extra-args", "'-o IdentitiesOnly=yes'") + } } args = append(args, p.config.ExtraArguments...)