Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 69e07b7

Browse files
committed
fix(cli): collection install path (#60)
1 parent c9b94fe commit 69e07b7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

ansible/collection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func GetCollectionDirs() ([]string, error) {
5555
var pathEnv = os.Getenv("COLLECTIONS_PATHS")
5656
var pathList []string
5757
if pathEnv == "" {
58-
pathList = []string{homeDir + "/.ansible/collections/ansible_collections"}
58+
pathList = []string{homeDir + "/.ansible/collections"}
5959
} else {
6060
pathList = strings.Split(pathEnv, ":")
6161
if len(pathList) == 0 {
62-
pathList = []string{homeDir + "/.ansible/collections/ansible_collections"}
62+
pathList = []string{homeDir + "/.ansible/collections"}
6363
}
6464
}
6565
return pathList, nil
@@ -73,7 +73,7 @@ func GetStackHeadCollectionLocation() (string, error) {
7373
}
7474
// Look for Ansible directory
7575
for _, singlePath := range collectionDirs {
76-
var installPath = filepath.Join(singlePath, "getstackhead", "stackhead")
76+
var installPath = filepath.Join(singlePath, "ansible_collections", "getstackhead", "stackhead")
7777
if _, err := os.Stat(installPath); !os.IsNotExist(err) {
7878
return installPath, nil
7979
}

routines/exec.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"os/exec"
8+
"path/filepath"
89
"strings"
910

1011
"github.com/spf13/viper"
@@ -48,7 +49,15 @@ func ExecAnsibleGalaxy(args ...string) error {
4849
if err != nil {
4950
return err
5051
}
51-
args = append(args, "-p "+collectionDir[0])
52+
53+
cwd, err := os.Getwd()
54+
if err != nil {
55+
return err
56+
}
57+
58+
// We have to set a relative path, otherwise ansible-galaxy will do weird things...
59+
relCollectionsPath, _ := filepath.Rel(cwd, "/")
60+
args = append(args, "-p "+relCollectionsPath+"/../.."+collectionDir[0])
5261
return Exec("ansible-galaxy", args...)
5362
}
5463

0 commit comments

Comments
 (0)