forked from toolshed/abra
@ -62,10 +62,12 @@ All communication between Abra and the server will use this SSH connection.
|
||||
|
||||
for _, context := range contexts {
|
||||
if context.Name == domainName {
|
||||
logrus.Fatalf("Server at '%s' already exists?", domainName)
|
||||
logrus.Fatalf("server at '%s' already exists?", domainName)
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("creating context with domain '%s', username '%s' and port '%s'", domainName, username, port)
|
||||
|
||||
if err := client.CreateContext(domainName, username, port); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -77,11 +79,12 @@ All communication between Abra and the server will use this SSH connection.
|
||||
}
|
||||
|
||||
if _, err := cl.Info(ctx); err != nil {
|
||||
logrus.Fatalf("Unable to make a connection to '%s'?", domainName)
|
||||
logrus.Fatalf("unable to make a connection to '%s'?", domainName)
|
||||
logrus.Debug(err)
|
||||
}
|
||||
|
||||
logrus.Infof("Server at '%s' has been added", domainName)
|
||||
logrus.Debugf("remote connection to '%s' is definitely up", domainName)
|
||||
logrus.Infof("server at '%s' has been added", domainName)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ var serverInitCommand = &cli.Command{
|
||||
HideHelp: true,
|
||||
ArgsUsage: "<domain>",
|
||||
Description: `
|
||||
Initialise swarm mode on the target <server>.
|
||||
Initialise swarm mode on the target <domain>.
|
||||
|
||||
This initialisation explicitly chooses the "single host swarm" mode which uses
|
||||
the default IPv4 address as the advertising address. This can be re-configured
|
||||
@ -45,6 +45,7 @@ later for more advanced use cases.
|
||||
return d.DialContext(ctx, "udp", "95.216.24.230:53")
|
||||
},
|
||||
}
|
||||
logrus.Debugf("created DNS resolver via 95.216.24.230")
|
||||
|
||||
ctx := context.Background()
|
||||
ips, err := resolver.LookupIPAddr(ctx, domainName)
|
||||
@ -64,11 +65,13 @@ later for more advanced use cases.
|
||||
if _, err := cl.SwarmInit(ctx, initReq); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("initialised swarm on '%s'", domainName)
|
||||
|
||||
netOpts := types.NetworkCreate{Driver: "overlay", Scope: "swarm"}
|
||||
if _, err := cl.NetworkCreate(ctx, "proxy", netOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debug("swarm overlay network 'proxy' created")
|
||||
|
||||
return nil
|
||||
},
|
||||
|
@ -22,6 +22,7 @@ var serverListCommand = &cli.Command{
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
tableColumns := []string{"Name", "Connection"}
|
||||
table := formatter.CreateTable(tableColumns)
|
||||
defer table.Render()
|
||||
@ -30,8 +31,8 @@ var serverListCommand = &cli.Command{
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
for _, serverName := range serverNames {
|
||||
|
||||
for _, serverName := range serverNames {
|
||||
var row []string
|
||||
for _, ctx := range contexts {
|
||||
endpoint, err := client.GetContextEndpoint(ctx)
|
||||
@ -47,9 +48,8 @@ var serverListCommand = &cli.Command{
|
||||
row = []string{serverName, "UNKNOWN"}
|
||||
}
|
||||
table.Append(row)
|
||||
|
||||
}
|
||||
return nil
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -79,12 +79,14 @@ environment variable or otherwise passing the "--env/-e" flag.
|
||||
}
|
||||
|
||||
if hetznerCloudAPIToken == "" {
|
||||
logrus.Fatal("Hetzner Cloud API token is missing, cannot continue")
|
||||
logrus.Fatal("Hetzner Cloud API token is missing")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
client := hcloud.NewClient(hcloud.WithToken(hetznerCloudAPIToken))
|
||||
|
||||
logrus.Debugf("successfully created hetzner cloud API client")
|
||||
|
||||
var sshKeys []*hcloud.SSHKey
|
||||
for _, sshKey := range c.StringSlice("ssh-keys") {
|
||||
sshKey, _, err := client.SSHKey.GetByName(ctx, sshKey)
|
||||
@ -106,13 +108,17 @@ environment variable or otherwise passing the "--env/-e" flag.
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
logrus.Debugf("new server '%s' created", name)
|
||||
|
||||
tableColumns := []string{"Name", "IPv4", "Root Password"}
|
||||
table := formatter.CreateTable(tableColumns)
|
||||
|
||||
if len(sshKeys) > 0 {
|
||||
table.Append([]string{name, res.Server.PublicNet.IPv4.IP.String(), "N/A (using SSH keys)"})
|
||||
} else {
|
||||
table.Append([]string{name, res.Server.PublicNet.IPv4.IP.String(), res.RootPassword})
|
||||
}
|
||||
|
||||
table.Render()
|
||||
|
||||
return nil
|
||||
@ -182,13 +188,14 @@ environment variable or otherwise passing the "--env/-e" flag.
|
||||
}
|
||||
|
||||
if capsulAPIToken == "" {
|
||||
logrus.Fatal("Capsul API token is missing, cannot continue")
|
||||
logrus.Fatal("Capsul API token is missing")
|
||||
}
|
||||
|
||||
// yep, the response time is quite slow, something to fix Capsul side
|
||||
// yep, the response time is quite slow, something to fix on the Capsul side
|
||||
client := &http.Client{Timeout: 20 * time.Second}
|
||||
|
||||
capsulCreateURL := fmt.Sprintf("https://%s/api/capsul/create", capsulInstance)
|
||||
logrus.Debugf("using '%s' as capsul create url", capsulCreateURL)
|
||||
values := map[string]string{
|
||||
"name": name,
|
||||
"size": capsulType,
|
||||
@ -230,6 +237,7 @@ environment variable or otherwise passing the "--env/-e" flag.
|
||||
if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debugf("capsul created with ID: '%s'", resp.ID)
|
||||
|
||||
tableColumns := []string{"Name", "ID"}
|
||||
table := formatter.CreateTable(tableColumns)
|
||||
|
@ -23,7 +23,7 @@ internal bookkeeping so that it is not managed any more.
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
logrus.Infof("Server at '%s' has been forgotten", domainName)
|
||||
logrus.Infof("server at '%s' has been forgotten", domainName)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
Reference in New Issue
Block a user