Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
exoscale: add an option to specify a SSH user
Browse files Browse the repository at this point in the history
Thanks to the last commit, it is now possible to spawn different images,
notably Debian and CoreOS. The default user in those images are not
"ubuntu". Let the user choose the appropriate user ("core" for CoreOS
and "debian" for Debian).

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
  • Loading branch information
vincentbernat committed Mar 21, 2016
1 parent fb6d511 commit 6a831d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/drivers/exoscale.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Options:
- `--exoscale-disk-size`: Disk size for the host in GB (10, 50, 100, 200, 400).
- `--exoscale-image`: Image template (eg. ubuntu-14.04, ubuntu-15.10).
- `--exoscale-security-group`: Security group. It will be created if it doesn't exist.
- `--exoscale-availability-zone`: exoscale availability zone.
- `--exoscale-availability-zone`: Exoscale availability zone.
- `--exoscale-ssh-user`: SSH username, which must match the default SSH user for the used image.

If a custom security group is provided, you need to ensure that you allow TCP ports 22 and 2376 in an ingress rule. Moreover, if you want to use Swarm, also add TCP port 3376.

Expand All @@ -41,3 +42,4 @@ Environment variables and default values:
| `--exoscale-image` | `EXOSCALE_IMAGE` | `ubuntu-15.10` |
| `--exoscale-security-group` | `EXOSCALE_SECURITY_GROUP` | `docker-machine` |
| `--exoscale-availability-zone` | `EXOSCALE_AVAILABILITY_ZONE` | `ch-gva-2` |
| `--exoscale-ssh-user` | `EXOSCALE_SSH_USER` | `ubuntu` |
14 changes: 13 additions & 1 deletion drivers/exoscale/exoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
defaultDiskSize = 50
defaultImage = "ubuntu-15.10"
defaultAvailabilityZone = "ch-gva-2"
defaultSSHUser = "ubuntu"
)

// GetCreateFlags registers the flags this driver adds to
Expand Down Expand Up @@ -88,6 +89,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Value: defaultAvailabilityZone,
Usage: "exoscale availibility zone",
},
mcnflag.StringFlag{
EnvVar: "EXOSCALE_SSH_USER",
Name: "exoscale-ssh-user",
Value: defaultSSHUser,
Usage: "Set the name of the ssh user",
},
}
}

Expand All @@ -109,7 +116,11 @@ func (d *Driver) GetSSHHostname() (string, error) {
}

func (d *Driver) GetSSHUsername() string {
return "ubuntu"
if d.SSHUser == "" {
d.SSHUser = defaultSSHUser
}

return d.SSHUser
}

// DriverName returns the name of the driver
Expand All @@ -130,6 +141,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
}
d.SecurityGroup = strings.Join(securityGroups, ",")
d.AvailabilityZone = flags.String("exoscale-availability-zone")
d.SSHUser = flags.String("exoscale-ssh-user")
d.SetSwarmConfigFromFlags(flags)

if d.URL == "" {
Expand Down

0 comments on commit 6a831d4

Please sign in to comment.