func (provisioner *DebianProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "aufs" } // HACK: since debian does not come with sudo by default we install log.Debug("installing sudo") if _, err := provisioner.SSHCommand("if ! type sudo; then apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y sudo; fi"); err != nil { return err } log.Debug("setting hostname") if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } log.Debug("installing base packages") for _, pkg := range provisioner.Packages { if err := provisioner.Package(pkg, pkgaction.Install); err != nil { return err } } log.Debug("installing docker") if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil { return err } log.Debug("waiting for docker daemon") if err := mcnutils.WaitFor(provisioner.dockerDaemonResponding); err != nil { return err } provisioner.AuthOptions = setRemoteAuthOptions(provisioner) log.Debug("configuring auth") if err := ConfigureAuth(provisioner); err != nil { return err } log.Debug("configuring swarm") if err := configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } // enable in systemd log.Debug("enabling docker in systemd") if err := provisioner.Service("docker", serviceaction.Enable); err != nil { return err } return nil }
func (provisioner *RedHatProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env // set default storage driver for redhat if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "devicemapper" } if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } for _, pkg := range provisioner.Packages { log.Debugf("installing base package: name=%s", pkg) if err := provisioner.Package(pkg, pkgaction.Install); err != nil { return err } } // update OS -- this is needed for libdevicemapper and the docker install if _, err := provisioner.SSHCommand("sudo yum -y update"); err != nil { return err } // install docker if err := installDocker(provisioner); err != nil { return err } if err := mcnutils.WaitFor(provisioner.dockerDaemonResponding); err != nil { return err } if err := makeDockerOptionsDir(provisioner); err != nil { return err } provisioner.AuthOptions = setRemoteAuthOptions(provisioner) if err := ConfigureAuth(provisioner); err != nil { return err } if err := configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } return nil }
func (provisioner *Boot2DockerProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { const ( dockerPort = 2376 ) var ( err error ) defer func() { if err == nil { provisioner.AttemptIPContact(dockerPort) } }() provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "aufs" } if err = provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } // b2d hosts need to wait for the daemon to be up // before continuing with provisioning if err = waitForDocker(provisioner, dockerPort); err != nil { return err } if err = makeDockerOptionsDir(provisioner); err != nil { return err } provisioner.AuthOptions = setRemoteAuthOptions(provisioner) if err = ConfigureAuth(provisioner); err != nil { return err } if err = configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } return nil }
func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "aufs" } if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } for _, pkg := range provisioner.Packages { if err := provisioner.Package(pkg, pkgaction.Install); err != nil { return err } } if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil { return err } if err := mcnutils.WaitFor(provisioner.dockerDaemonResponding); err != nil { return err } if err := makeDockerOptionsDir(provisioner); err != nil { return err } provisioner.AuthOptions = setRemoteAuthOptions(provisioner) if err := ConfigureAuth(provisioner); err != nil { return err } if err := configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } return nil }
func (provisioner *RancherProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "overlay" } else if provisioner.EngineOptions.StorageDriver != "overlay" { return fmt.Errorf("Unsupported storage driver: %s", provisioner.EngineOptions.StorageDriver) } log.Debugf("Setting hostname %s", provisioner.Driver.GetMachineName()) if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } for _, pkg := range provisioner.Packages { log.Debugf("Installing package %s", pkg) if err := provisioner.Package(pkg, pkgaction.Install); err != nil { return err } } log.Debugf("Preparing certificates") provisioner.AuthOptions = setRemoteAuthOptions(provisioner) log.Debugf("Setting up certificates") if err := ConfigureAuth(provisioner); err != nil { return err } log.Debugf("Configuring swarm") if err := configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } return nil }
func (provisioner *ArchProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions, engineOptions engine.EngineOptions) error { provisioner.SwarmOptions = swarmOptions provisioner.AuthOptions = authOptions provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env if provisioner.EngineOptions.StorageDriver == "" { provisioner.EngineOptions.StorageDriver = "overlay" } // HACK: since Arch does not come with sudo by default we install log.Debug("Installing sudo") if _, err := provisioner.SSHCommand("if ! type sudo; then pacman -Sy --noconfirm --noprogressbar sudo; fi"); err != nil { return err } log.Debug("Setting hostname") if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil { return err } log.Debug("Installing base packages") for _, pkg := range provisioner.Packages { if err := provisioner.Package(pkg, pkgaction.Install); err != nil { return err } } log.Debug("Installing docker") if err := provisioner.Package("docker", pkgaction.Install); err != nil { return err } log.Debug("Starting systemd docker service") if err := provisioner.Service("docker", serviceaction.Start); err != nil { return err } log.Debug("Waiting for docker daemon") if err := mcnutils.WaitFor(provisioner.dockerDaemonResponding); err != nil { return err } provisioner.AuthOptions = setRemoteAuthOptions(provisioner) log.Debug("Configuring auth") if err := ConfigureAuth(provisioner); err != nil { return err } log.Debug("Configuring swarm") if err := configureSwarm(provisioner, swarmOptions, provisioner.AuthOptions); err != nil { return err } // enable in systemd log.Debug("Enabling docker in systemd") if err := provisioner.Service("docker", serviceaction.Enable); err != nil { return err } return nil }