diff --git a/README.md b/README.md index d6fc724f..ecc5d912 100644 --- a/README.md +++ b/README.md @@ -792,6 +792,15 @@ backends: image: ubuntu:16.04.1 ``` +Additionally, you can provide a comma-seperated list of LXD profiles to use: +``` +backends: + lxd: + container-profiles: my-profile + systems: + - ubuntu-16.04 +``` + That's it. Have fun with your self-contained multi-system task runner. diff --git a/spread/lxd.go b/spread/lxd.go index 2cbf9974..d81d3793 100644 --- a/spread/lxd.go +++ b/spread/lxd.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "gopkg.in/yaml.v2" "io/ioutil" "os" "os/exec" @@ -15,6 +14,8 @@ import ( "syscall" "time" + "gopkg.in/yaml.v2" + "golang.org/x/net/context" ) @@ -111,6 +112,12 @@ func (p *lxdProvider) Allocate(ctx context.Context, system *System) (Server, err if !p.options.Reuse { args = append(args, "--ephemeral") } + if p.backend.ContainerProfiles != "" { + profiles := strings.Split(p.backend.ContainerProfiles, ",") + for _, profile := range profiles { + args = append(args, "--profile", profile) + } + } output, err := exec.Command("lxc", args...).CombinedOutput() if err != nil { err = outputErr(output, err) diff --git a/spread/project.go b/spread/project.go index e70470f0..c781f0cd 100644 --- a/spread/project.go +++ b/spread/project.go @@ -59,6 +59,9 @@ type Backend struct { // Only for qemu so far. Memory Size + // Only for LXD so far. + ContainerProfiles string `yaml:"container-profiles"` + // Only for Linode and Google so far. Plan string Location string