Add many servers at once
A fleet install code adds many servers with one code: from cloud-init, Ansible, a server image or a loop over SSH. New servers wait for your approval before anything runs on them.
One server or many?
For one server, use Servers → Add server: you get an install code that works once. For many servers, use Servers → Add many servers. A fleet install code works again and again, until it expires, is used up or you revoke it. Only owners and admins can make one.
How it works
- Make a code. ServerNest asks for your password again, then shows the code once. Copy it somewhere safe: ServerNest can't show it again.
- On each new server, the installer runs with the code in a file that only root can read. The code is never typed on a command line, so it doesn't show in the list of running programs or in the shell history.
- The server connects out to ServerNest (no open ports) and shows up on the Servers page as Waiting for approval. Nothing runs on it yet.
- Check its name, hostname and address, then Approve or Reject it, one at a time or several at once. Rejecting removes it and disconnects it.
Settings
Only the name and the number of days are needed. The rest is optional.
| Setting | What it does | Example |
|---|---|---|
| Name of the code | Your label for it. | Autoscaling web servers |
| Works for (days) | 1 to 90 days. Then the code stops working. | 1 |
| Most servers it can add | The code stops after this many servers. Your plan's server limit always counts too. | 20 |
| Server names to use | Each new server takes the next unused name, in order. | web-1, web-2, web-3 |
| Start of the name | Put in front of names made from the hostname. | web- → web-node-01 |
| Labels | Every server the code adds gets them. Search for them in the server list. | web, eu-west |
| Only from these addresses | Servers can only join from these addresses or ranges (IPv4 or IPv6), up to 20. | 203.0.113.0/24 |
| Approve new servers automatically | Off by default. When on, new servers get actions right away. We don't recommend it. |
Server names
- If you list names, each new server takes the next unused one. Two servers joining at the same time never get the same name.
- A name that another server got after you made the code is skipped. The code's page shows which names are used, not used yet, or skipped.
- When the list runs out, the server is named after its hostname, with your "start of the name" in front. You can also choose a name on one server with
--name web-7. If the name is taken, a short random ending is added, for exampleweb-node-01-3fa9c1.
Allowed addresses
- The address that counts is the one ServerNest sees the server connect from: its public address, or your network's outgoing address for servers in a private network.
- A server at another address is refused. The installer says "This fleet code can not be used from this server's address", nothing is added, and the attempt is in your activity log.
- To allow every address, leave the field empty.
0.0.0.0/0and::/0are not accepted.
Examples
Right after you make a code, the dashboard shows these with your code filled in.
cloud-init
Programs on the new server can read its user data, so keep the code short-lived, limited, and with approval on.
#cloud-config
write_files:
- path: /root/servernest-code
owner: root:root
permissions: "0600"
content: |
YOUR-FLEET-CODE
runcmd:
- curl -fsSL https://app.servernest.io/install.sh -o /root/servernest-install.sh
- sh /root/servernest-install.sh --token-file /root/servernest-code
- rm -f /root/servernest-code /root/servernest-install.sh
Ansible
Store the code encrypted with ansible-vault encrypt_string --stdin-name servernest_fleet_code. Write it to /root/servernest-code with mode 0600 and no_log: true, run the installer with --token-file /root/servernest-code, then delete the file.
A list of servers over SSH
for host in web-1.example.com web-2.example.com; do
ssh root@"$host" 'umask 077; cat > /root/servernest-code' < ./fleet-code
ssh root@"$host" 'curl -fsSL https://app.servernest.io/install.sh | sh -s -- --token-file /root/servernest-code; rm -f /root/servernest-code'
done
When a code stops working
A code stops when it expires, when you revoke it, when it has added its most servers, or when your plan's server limit is reached. The installer says so in plain words. Servers it already added stay.
Keep the code safe
- Treat it like a password. Anyone with the code can ask to add a server to your account.
- Keep approval on, keep the days short, and set "Most servers" and allowed addresses when you can.
- Revoke a code you no longer need: Servers → Add many servers, open the code, Revoke code.
- Every code made, revoked or refused, and every server added, approved or rejected, is in your activity log.
Related: pricing.