github.com/rohankumardubey/nomad@v0.11.8/e2e/framework/provisioning/config_vagrant.go (about)

     1  package provisioning
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  )
     7  
     8  // ProvisionerConfigVagrant targets a single-node Vagrant environment.
     9  func ProvisionerConfigVagrant(config ProvisionerConfig) *ProvisioningTargets {
    10  
    11  	if config.NomadVersion == "" && config.NomadSha == "" && config.NomadLocalBinary == "" {
    12  		log.Fatal("cannot run vagrant provisioning without a '-nomad.*' flag set")
    13  		return nil
    14  	}
    15  
    16  	// TODO(tgross): need a better way to get the right root path, rather
    17  	// than relying on running at the root of the Nomad source directory.
    18  	keyPath := fmt.Sprintf(
    19  		"./.vagrant/machines/%s/virtualbox/private_key", config.VagrantBox)
    20  
    21  	return &ProvisioningTargets{
    22  		Servers: []*ProvisioningTarget{
    23  			{
    24  				Runner: map[string]interface{}{}, // unused
    25  				runner: &SSHRunner{
    26  					Key:  keyPath,
    27  					User: "vagrant",
    28  					Host: "127.0.0.1",
    29  					Port: 2222,
    30  				},
    31  				Deployment: Deployment{
    32  					NomadLocalBinary: config.NomadLocalBinary,
    33  					NomadSha:         config.NomadSha,
    34  					NomadVersion:     config.NomadVersion,
    35  					RemoteBinaryPath: "/opt/gopath/bin/nomad",
    36  					Platform:         "linux_amd64",
    37  					Bundles: []Bundle{
    38  						// TODO(tgross): we need a shared vagrant config
    39  						// and service file for this to work.
    40  						{
    41  							Source:      "./config.hcl",
    42  							Destination: "/home/vagrant/config.hcl",
    43  						},
    44  					},
    45  					Steps: []string{
    46  						"sudo systemctl restart consul",
    47  						"sudo systemctl restart nomad",
    48  					},
    49  				},
    50  			},
    51  		},
    52  	}
    53  }