github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/environs/manual/provisioner.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Copyright 2016 Cloudbase Solutions SRL 3 // Licensed under the AGPLv3, see LICENCE file for details. 4 5 package manual 6 7 import ( 8 "errors" 9 "io" 10 "time" 11 12 "github.com/juju/juju/rpc/params" 13 ) 14 15 var ( 16 // ErrProvisioned is returned by ProvisionMachine if the target 17 // machine has an existing machine agent. 18 ErrProvisioned = errors.New("machine is already provisioned") 19 ) 20 21 // ProvisionMachineFunc that every provisioner should have 22 type ProvisionMachineFunc func(ProvisionMachineArgs) (machineId string, err error) 23 24 // ProvisionMachineArgs used for arguments for the Provisioner methods 25 type ProvisionMachineArgs struct { 26 // user and host of the ssh or winrm conn 27 Host string 28 User string 29 30 // DataDir is the root directory for juju data. 31 // If left blank, the default location "/var/lib/juju" will be used. 32 DataDir string 33 34 // Client provides the API needed to provision the machines. 35 Client ProvisioningClientAPI 36 37 // Stdin is required to respond to sudo prompts, 38 // and must be a terminal (except in tests) 39 Stdin io.Reader 40 41 // Stdout is required to present sudo prompts to the user. 42 Stdout io.Writer 43 44 // Stderr is required to present machine provisioning progress to the user. 45 Stderr io.Writer 46 47 // AuthorizedKeys contains the concatenated authorized-keys to add to the 48 // ubuntu user's ~/.ssh/authorized_keys. 49 AuthorizedKeys string 50 51 // PrivateKey contains the path of the identify file containing the 52 // private key to be used during the ssh connection with a target 53 // machine. 54 PrivateKey string 55 56 *params.UpdateBehavior 57 } 58 59 // ProvisioningClientAPI defines the methods that are needed for the manual 60 // provisioning of machines. An interface is used here to decouple the API 61 // consumer from the actual API implementation type. 62 type ProvisioningClientAPI interface { 63 AddMachines([]params.AddMachineParams) ([]params.AddMachinesResult, error) 64 DestroyMachinesWithParams(force, keep, dryRun bool, maxWait *time.Duration, machines ...string) ([]params.DestroyMachineResult, error) 65 ProvisioningScript(params.ProvisioningScriptParams) (script string, err error) 66 }