Scaleway DocumentationComputeBare Metal CloudAPI/CLI
Managing Bare Metal servers with the CLI

Jump toUpdate content

Creating and Managing a Bare Metal server using the Scaleway Command Line Interface (CLI)

Scaleway’s Bare Metal Cloud Servers provide you with dedicated servers on-demand, with all the benefits of the cloud including flexibility and hourly billing. These servers are great for large workloads, big data and (because no-one else is sharing your server) applications that require increased security and dedicated resources.

You can create and manage your Bare Metal servers from the console, via the API or via the Scaleway Command Line Interface.

Scaleway Command Line Interface Overview

The Scaleway Command Line Interface (CLI) allows you to pilot your Scaleway infrastructure directly from your terminal, providing a faster way to administer and monitor your resources. Scaleway CLI is easy to set up and use, and an essential tool for operating efficiently in your cloud environment. The CLI provides many functionalities, including the ability to create and administer Bare Metal Servers.

Requirements:

Configuring the CLI

  1. You must configure the Scaleway CLI on your machine. Open a terminal and type the following command:

    scw init

    If you have already configured the CLI, you will see a message like the following:

    Current config is located at /path/to/config.yamlaccess_key: <YOUR ACCESS KEY>secret_key: <YOUR SECRET KEY>default_organization_id: <YOUR ORGANIZATION ID>default_project_id: <YOUR PROJECT ID>default_region: <YOUR DEFAULT REGION, eg fr-par>default_zone: <YOUR DEFAULT ZONE, eg fr-par-1>
    Do you want to override the current config? (Y/n):  
  2. Unless you want to change your configuration, you can type n and go directly to the Creating a Bare Metal Server step of this tutorial.

    If you have not yet configured the CLI, you will be guided through the configuration process via a series of questions:

    Enter a valid secret-key or an email
  3. Enter either the email address for your account (you will then be asked for your password), or your API Secret Key

    To improve this tool we rely on diagnostic and usage data.Sending such data is optional and can be disabled at any time by running "scw config set send-telemetry=false".Do you want to send usage statistics and diagnostics? (Y/n):
  4. Type y or n and hit enter.

    To fully enjoy Scaleway CLI we recommend you install autocomplete support in your shell.Do you want to install autocomplete? (Y/n):
  5. Type y or n and hit enter.

    To enable autocomplete, scw needs to update your shell configuration.What type of shell are you using (default: bash):
  6. Hit enter if the default shell type is already correct for you. Otherwise, enter your shell type and hit enter. This should complete the configuration process:

    Initialization completed with success.

Creating a Bare Metal Server

1 . You can use the command scw baremetal server create to create your Bare Metal Server. First, let’s view the help info for this command. Type:

scw baremetal server create --help

You will see an output like the following:

Create a new baremetal server. Once the server is created, you probably want to install an OS.
USAGE:  scw baremetal server create [arg=value ...]
EXAMPLES:  Create instance    scw baremetal server create
  Create a GP-BM1-M instance, give it a name and add tags    scw baremetal server create name=foo tags.0=prod tags.1=blue type=GP-BM1-M
ARGS:  [project-id]                    Project ID to use. If none is passed the default project ID will be used  name=<generated>                Name of the server (≠hostname)  [description]                   Description associated to the server, max 255 characters  [type=GP-BM1-S]                 Server commercial type (GP-BM1-L | GP-BM1-M | GP-BM1-S | HC-BM1-L | HC-BM1-S | HM-BM1-XL | HM-BM1-M)  [tags.{index}]                  Tags to associate to the server  [install.os-id]                   [install.hostname]                [install.ssh-key-ids.{index}]     [organization-id]               Organization ID to use. If none is passed the default organization ID will be used  [zone=fr-par-1]                 Zone to target. If none is passed will use default zone from the config (fr-par-2)
FLAGS:  -h, --help   help for create  -w, --wait   wait until the server is ready
GLOBAL FLAGS:  -c, --config string    The path to the config file  -D, --debug            Enable debug mode  -o, --output string    Output format: json or human, see 'scw help output' for more info (default "human")  -p, --profile string   The config profile to use
SEE ALSO:  # List os  scw baremetal os list
  # Install an OS on your server  scw baremetal server install

In ARGS you see all the options for creating your Bare Metal server, including the different types of server available (GP-BML-L, GP-BM1-M etc).

: The help info for the `zone` argument says that the default zone is `fr-par-2`. In fact, `fr-par-2` is the only zone in which Bare Metal servers are available at the moment, but it is not necessarily the default zone in your configuration. To create a Bare Metal server, you need to either: a) change the default zone in your configuration file (check the location of this file in the output of sw init and change the value for `default zone` to `fr-par-2`), or b) explicitly target the fr-par-2 zone in the commands to create and manage your server.

In this tutorial, we’ll target the zone explicitly in our commands.

  1. Type the following command into your terminal to create a Bare Metal server. You can choose the value for name, but remember the server type must be one from the list we saw in the previous step, and the zone must be fr-par-2:

    scw baremetal server create name=bm-tutorial-server type=GP-BM1-M zone=fr-par-2
    Note:

    Optionally, you can include additional arguments as per the ARGS information we just saw, eg description to add a description of your Bare Metal server, or tags.0 to add tags.

    You should see output in the console showing the API request and response, and finally confirming the ID and details of your server:

    ID              <ID of the Bare Metal Server>OrganizationID  <Your Organization ID>ProjectID       <Your Project ID>Name            bm-tutorial-serverDescription     -UpdatedAt       nowCreatedAt       nowStatus          deliveringOfferID         <Offer ID>Tags.0          -Domain          -BootType        normalZone            fr-par-2PingStatus      unknown
  2. Note down the ID of your Bare Metal server, as you will need it in the next step.

    Note:

    You can view a summary of information for your Bare Metal server, and details for any other Bare Metal servers you have previously created, by typing scw baremetal server list zone=fr-par-2. For full information, use the command scw baremetal server get <Server ID> zone=fr-par-2

Installing an OS

Now that you have created your Bare Metal server, the next thing you will probably want to do is install an OS.

  1. To see a list of available OSes, type:

    scw baremetal os list zone=fr-par-2

    You will see an output with available OSes and their associated IDs:

    ID                                    NAME    VERSION03b7f4ba-a6a1-4305-984e-b54fafbf1681  Ubuntu  20.0460f5d1e3-fa69-45af-9fc0-c9e3c114dd09  Ubuntu  19.1086fd5e3a-b023-4fa8-a3ae-1a194d8cd68c  CentOS  8f2aeab5d-6015-4b7c-b4ed-d76e89093621  Debian  10eef03f45-057b-4192-b95f-c21cae01e959  Debian  9d17d6872-0412-45d9-a198-af82c34d3c5c  CentOS  7.6d859aa89-8b4a-4551-af42-ff7c0c27260a  Ubuntu  18.043ea52186-1e57-499e-8146-ab38051a5c10  Ubuntu  BigBlueButton 16.04
  2. Note down the ID of you the OS you want to install.

  3. To install your chosen OS on your Bare Metal server, you will also need to know the SSH Key ID associated with your account. Type:

    scw account ssh-key list

    You will see an output like:

    ID                 NAME                    CREATED AT  UPDATED AT  PROJECT ID<YOUR SSH KEY ID>  <NAME OF YOUR SSH KEY>  1 week ago  1 week ago  <YOUR PROJECT ID>         
  4. Note down your SSH Key ID.

  5. Now that you have the ID of the OS you want to install and the ID of your SSH Key, you can install an OS on your Bare Metal server with the following command. Remember to replace the values of the arguments with the correct values for your IDs. Note that the hostname does not have to be the same as the Server Name you chose in step 2.2.

    scw baremetal server install <Bare Metal Server ID> os-id=<OS ID> hostname=<Hostname for the Server> ssh-key-ids.0=<SSH Key ID> zone=fr-par-2

    Note: If you have multiple SSH keys, you can use the argument all-ssh-keys=true to install all your SSH keys on the server

    You should see an output similar to the following, which confirms that the OS is being installed:

    ID                          <ID of the Bare Metal Server>OrganizationID              <Your Organization ID>ProjectID                   <Your Project ID>Name                        bm-tutorial-serverDescription                 -UpdatedAt                   8 minutes agoCreatedAt                   11 minutes agoStatus                      readyOfferID                     <Offer ID>Tags.0                      -IPs.0.ID                    <IPs.0.ID >IPs.0.Address               <IPs.0.Address>IPs.0.Reverse               <IPs.0.Reverse>IPs.0.Version               IPv4IPs.0.ReverseStatus         activeIPs.0.ReverseStatusMessage  -IPs.1.ID                    <IPs.1.ID >IPs.1.Address               <IPs.1.Address>IPs.1.Reverse               <IPs.1.Reverse>IPs.1.Version               IPv6IPs.1.ReverseStatus         activeIPs.1.ReverseStatusMessage  -Domain                      <domain>.fr-par-2.baremetal.scw.cloudBootType                    normalZone                        fr-par-2Install.OsID                <OS ID>Install.Hostname            <Server Hostname>Install.SSHKeyIDs.0         2d93ac50-1a57-4476-b686-16b514a35931Install.Status              to_installPingStatus                  down

    Installation of the OS should take less than one hour. You can use the scw baremetal server list zone=fr-par-2 command again if you wish, to check whether the status of your server has moved from Installing to Ready.

Using other CLI commands

There are many other functionalities you can access for your Bare Metal Server via the Scaleway CLI. In the following examples, replace the Bare Metal Server ID with the ID of your Bare Metal server:

Note:

Before powering off your Bare Metal server, you should log into your server as root and execute the halt command to shutdown the OS. If you’re not sure of the IP address of your Bare Metal server, for login purposes, use the scw baremetal server get <Server-ID/> zone=fr-par-2 command to see this information in the IPs.0.Address field

-To power off your Bare Metal Server, use the following command:

scw baremetal server stop <Bare Metal Server ID> zone=fr-par-2

-To power on your Bare Metal Server, use the following command:

scw baremetal server start <Bare Metal Server ID> zone=fr-par-2

-To reboot your Bare Metal Server, use the following command:

scw baremetal server reboot <Bare Metal Server ID> zone=fr-par-2

For further information, execute the help command:

scw baremetal server --help

Deleting your Bare Metal Server

Note:

This will permanently delete your Bare Metal server and all your data will be lost. This action is irreversible.

When you want to remove your Bare Metal server, at the end of its lifecycle, you can delete it with the following command.

scw baremetal server reboot <Bare Metal Server ID> zone=fr-par-2

You will see an output like the following:

ID                           ID of the Bare Metal Server>OrganizationID              <Your Organization ID>ProjectID                   <Your Project ID>Name                        bm-tutorial-serverDescription                 -UpdatedAt                   nowCreatedAt                   4 hours agoStatus                      deletingOfferID                     <Offer ID>Tags.0                      -IPs.0.ID                    <IPs.0.ID>IPs.0.Address               <IPs.0.Address>IPs.0.Reverse               <IPs.0.Reverse>IPs.0.Version               IPv4IPs.0.ReverseStatus         activeIPs.0.ReverseStatusMessage  -IPs.1.ID                    <IPs.1.ID>IPs.1.Address               <IPs.1.Address>IPs.1.Reverse               <IPs.1.Reverse>IPs.1.Version               IPv6IPs.1.ReverseStatus         activeIPs.1.ReverseStatusMessage  -Domain                      <Domain>BootType                    normalZone                        fr-par-2Install.OsID                <Install.OsID>Install.Hostname            <Install.Hostname>Install.SSHKeyIDs.0         <Install.SSHKeyIDs.0>Install.Status              completedPingStatus                  down

Note that the status field now says deleting. The deletion process may take a few minutes. You can check that your Bare Metal server has been deleted by verifying that it is not returned when you enter the command:

scw baremetal server list zone=fr-par-2

Conclusion and going further

You now know how to create a Bare Metal server via the Scaleway CLI, as well as install an OS, power the server off and on, reboot it, and delete it. You can use the --help command as described with the Scaleway CLI to find more information about its different functionalities and parameters. More information about the Scaleway CLI is available in the GitHub documentation. Alternatively, check out our other Bare Metal documentation.