Skip to content

Commit

Permalink
fix: specify ansible config path explicitly with ANSIBLE_CONFIG
Browse files Browse the repository at this point in the history
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.

Signed-off-by: ludo <[email protected]>
  • Loading branch information
spiarh committed Jan 8, 2024
1 parent f5bd876 commit c6f8116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/tools/ansible.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

const (
AnsiblePlaybookExecutable Executable = "ansible-playbook"
AnsibleConfigPath string = "/simulator/config/admin/ansible.cfg"
)

type ScenarioManager interface {
Expand Down Expand Up @@ -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},
}
}

Expand Down
2 changes: 2 additions & 0 deletions core/tools/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Executable string
type runner struct {
Executable Executable
WorkingDir string
Env []string
Arguments []string
}

Expand All @@ -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 {
Expand Down

0 comments on commit c6f8116

Please sign in to comment.