Moving a host
Take a host over in another Rookery installation, or get a lost profile back, from the copy of its profile that the host keeps.
Every apply and every first boot from a seed leaves the host's profile on the host, at /etc/rookery/profile.json. Only root can read it. A Rookery installation that does not have the profile can take the host over from it with rookery host adopt. This helps when:
- you move to another Rookery installation
- an installation lost its profiles
- a broken set-up needs repair, even when rookeryd on the host does not answer
The kept profile
The file contains the profile as Rookery stores it, with a few fields left out:
| Field | Kept | Why |
|---|---|---|
| Tailscale keys and the login server | No | Rookery makes a key when the host has to join the tailnet again, at the control server of its own settings |
access | No | rookery host adopt sets the address, user and port from how it reached the host. A key name means a key of the old installation's key ring, and a link command is a program of the old installation's machine |
builder.served | No | A server of the old installation means nothing to another one |
secrets, registries | Names only | Their values stay in each Rookery's own store and are never in a profile |
operator_password_hash, agent_password_hash | Yes | They are in /etc/shadow already. Without its hash, an apply would lock the agent's password |
wifi | Yes | The USB installer wrote the same network into the host's network settings |
| The machine a provisioner made | Yes | Its record, so it is still a resource of the host. Its token is a label on the machine and does not grant access |
The file also says its format, the version of the Rookery that wrote it, the time, and the host's name there. A Rookery that does not know the format refuses the file and asks to be updated.
rookeryd serves the same file to an administrator as GET /v1/applied/profile. Through a Rookery server that is GET /v1/hosts/NAME/controller/applied/profile.
Adopt a host
rookery host adopt studio ops@192.0.2.10
rookery apply studiorookery host adopt NAME [USER@]ADDRESS logs in over SSH as a user who can become root, reads the file with sudo and saves it as host NAME. It does not need rookeryd. --port PORT gives another SSH port. --key FILE offers one more private key for this read only. --force replaces a saved host of the same name. Without it, Rookery refuses.
Without an address, rookery host adopt NAME adopts the saved host NAME at the address its profile has. This is the way for a workstation that was saved by its address with rookery host add, whose profile here says less than the host keeps. rookery host add suggests the command when it finds such a host. A host saved as a workstation already needs --force.
The profile's access comes from how Rookery got in. It logs in with rookery when this Rookery's own key worked, and with ssh when your SSH configuration, your agent or the key of --key did. sudo is password when sudo asked for one. After the first apply, the operator takes this Rookery's key, and an apply as the operator sets sudo to none (Logging in to hosts).
Rookery asks on the terminal for a sudo password when sudo on the host needs one. Without a terminal, --sudo-password-stdin reads it from standard input.
The output lists what the profile names and this Rookery lacks: secret values and registries. Set them before you apply. rookery apply then makes the host this Rookery's.
With a Rookery server, rookery host adopt runs on the server: the server logs in to the host, reads the file and saves the host. The server applies with its own key, and it does not take the record of a machine a provisioner made.
Getting in
rookery host adopt logs in with this Rookery's own key, your SSH agent and your usual keys. The new installation's key is not on the host yet, so use one of these two ways.
Bring the old installation's key
Give rookery host adopt the old installation's private key with --key FILE. Rookery keeps its key in its store, and writes it to keys/rookery in its data directory, ~/.local/share/rookery by default, when it logs in to a host. Copy it through a pipe, so the key is never part of a command line:
umask 077
ssh old-machine 'cat ~/.local/share/rookery/keys/rookery' > old-rookery.key
rookery host adopt studio ops@192.0.2.10 --key old-rookery.key
rookery key import old-rookery old-rookery.key
rookery key trust studio --key old-rookery
rookery key remove old-rookery
rm old-rookery.keyrookery key trust logs in once with the old key and gives the operator this Rookery's key. The first apply then logs in without the old key. The key file is never saved.
Authorize the new installation's key
Print the new installation's public key:
rookery key showFor a Rookery server, run rookery key show as the user that runs rookery serve, or copy This Rookery's SSH key from the Settings tab of its page.
Add that line to ~/.ssh/authorized_keys of the operator on the host. Do it from the machine's console or from any login you still have:
echo 'ssh-ed25519 AAAA… rookery@new-machine' >> ~/.ssh/authorized_keysThe keys after the first apply
In the operator's authorized_keys, the keys in the profile have one block. Each installation that applies the host has a block of its own, named ROOKERY and an ID. No later apply removes an installation's block. So after the first apply of the new installation:
- the new installation's key is in its own block
- the old installation's key is still in its block, and the old installation still has access
- lines outside the blocks stay, such as a key you added by hand
The new installation then logs in with its own key. You can remove the line you added.
To take the old installation's access away, delete its block on the host as the operator. ID is the hex after # BEGIN ROOKERY on the line above the old installation's key:
sed -i '/^# BEGIN ROOKERY ID$/,/^# END ROOKERY ID$/d' ~/.ssh/authorized_keysAn installation that still has the host
There is nothing to do. Each apply writes the file again when the profile changed. The host keeps the profile of its last apply.
Renaming a host
A host keeps its machine when it gets another name in Rookery:
rookery host rename test studioRookery moves everything it keeps under the old name to the new one, in one change of its store:
| What | Moves |
|---|---|
| The profile and the passwords Rookery generated | Yes |
| The host keys Rookery recorded, and the passwords it logs in with | Yes |
| The record of its machine and its other resources | Yes, under the same id |
| Its messages, its jobs and where its channel was read up to | Yes |
| The machine, its hostname and its name on the tailnet | No, unless --hostname |
The provisioner's name for the machine, such as the Incus instance rookery-test | No |
With --hostname, the new name becomes the profile's hostname as well. The machine takes it at its next apply, which also writes the profile the host keeps with the new name. On a tailnet, that apply renames the host's device too, when Rookery has the API key. The name has to suit a hostname then: lower-case letters, digits and -.
Rookery refuses when a host has the new name already. A job that is creating the host's machine blocks the rename until that job ends. To keep the host and make another like it, duplicate it instead. When a Rookery server keeps the host, the server renames it as a job. On its overview and over the server's API it's the host's action Rename, rename.
Last updated on