diff --git a/core/tools/ansible.go b/core/tools/ansible.go index 9622141a..50b7ad23 100644 --- a/core/tools/ansible.go +++ b/core/tools/ansible.go @@ -11,6 +11,7 @@ import ( const ( AnsiblePlaybookExecutable Executable = "ansible-playbook" + AnsibleConfigPath string = "/simulator/config/admin/ansible.cfg" ) type ScenarioManager interface { @@ -61,6 +62,11 @@ func ansiblePlaybookCommand(workingDir, playbookDir, playbook string, extraVars Executable: AnsiblePlaybookExecutable, WorkingDir: workingDir, Arguments: args, + // Ansible complains on Windows+WSL that the directory + // with the ansible configuration is world writable + // and hence ignore the configuration unless explicitly + // set using the ANSIBLE_CONFIG environment variable. + Env: []string{"ANSIBLE_CONFIG=" + AnsibleConfigPath}, } } diff --git a/core/tools/runner.go b/core/tools/runner.go index f428ef54..edc308d3 100644 --- a/core/tools/runner.go +++ b/core/tools/runner.go @@ -14,6 +14,7 @@ type Executable string type runner struct { Executable Executable WorkingDir string + Env []string Arguments []string } @@ -25,6 +26,7 @@ func (c runner) Run(ctx context.Context, output io.Writer) error { cmd.Dir = c.WorkingDir cmd.Stdout = output cmd.Stderr = output + cmd.Env = c.Env err := cmd.Run() if err != nil {