Skip to content

Move a host from one zone to another

Move a workstation or a server to another zone, during a move for instance. The host’s zone key carries most of the change ; its backups, the services it hosts and the deployment order remain to be handled.

A gateway does not change zone, it defines it. To replace one, see Migrate gateway hardware.

Regenerated by just clean, then propagated to the deployment.

Handled automaticallyWhy
Address, DNS and DHCPDerived from the zone key
Gateway address in the old zoneSame last octet everywhere
Supervision and logsFeatures attached to the zone
Zone binary cacheSelected according to the zone
Zone-scoped firewallFollows the zone prefix
Users, secrets, SSH keysZone-independent
ItemRiskTo do
Restic backupsTarget and passphrase follow the zonePin the old server
Hosted servicesChange zone and URLWarn users
Features in :<zone>Explicit zone, does not followFix the zone
Time zone, localeThose of the new zoneOverride if needed
Machine configuration citing zoneFollows the declared zoneReview usr/machines/<host>/

A hosted service moves from <service>.<old-zone>.domain.tld to <service>.<new-zone>.domain.tld and now only serves its new zone. A global service keeps its public address, relayed by the HCS.

Fenêtre de terminal
grep -rn 'zone\.' usr/machines/poste/

Time zone and locale are overridden via darkone.system.i18n.timeZone and darkone.system.i18n.locale.

Example : poste leaves the maison zone (10.0) for the atelier zone (10.1).

  1. Enable the roaming cache

    Substituters become neutral and follow the zone the machine is plugged into, which saves the first deployment after the move from downloading through the VPN. See Binary cache.

    usr/machines/poste/configuration.nix
    darkone.service.nix-cache.roaming = true;
    Fenêtre de terminal
    just apply poste
  2. Change the zone

    Pick a free address according to the addressing convention of the destination zone.

    etc/config.yaml
    - hostname: "poste"
    zone: "atelier:2.1" # old value: "maison:2.1"
    mac: "aa:bb:cc:dd:ee:ff"
  3. Pin the backups

    To keep the history, the target continues to point at the old zone’s server, with that zone’s passphrase.

    usr/machines/poste/configuration.nix
    darkone.service.restic = {
    enable = true;
    targets = [
    {
    root = "rest:http://100.64.0.20:8888"; # tailnet IP of the maison server
    zone = "maison"; # restic-password-maison passphrase
    categories = [ "system" ];
    }
    ];
    };

    On the server side, listenAll must be enabled: see Off-site backups.

  4. Regenerate and validate

    Fenêtre de terminal
    just clean
    git diff var/generated/
    just commit "chore(poste): move from maison to atelier"

    The diff must show the fixed address in atelier and a 10.0.6.x gateway address in maison.

  5. Prepare the arrival

    Deploy the HCS, then the destination gateway, then the other gateways, except the departure one.

    Fenêtre de terminal
    just apply hcs
    just apply gw-atelier # then the other gateways, except gw-maison

    The destination gateway reserves the new address on the host’s MAC address. The HCS relays global services and enforces the VPN rules of the administration workstations : both target the host’s address.

  6. Move the machine

    Once plugged into atelier, it receives its new address via DHCP, before any redeployment.

  7. Finish the gateways

    With the host gone, the departure gateway can publish its new name and reserve its gateway address.

    Fenêtre de terminal
    just apply gw-maison
  8. Deploy the host

    Fenêtre de terminal
    just apply poste
  9. Verify

    • dig poste.atelier.domain.tld returns the new address.
    • The poste target is UP in the atelier Prometheus.
    • A manual backup finds the old snapshots.
  10. Remove the roaming cache

    Delete darkone.service.nix-cache.roaming, except for a laptop that frequently changes zone, then just apply poste.

What if the host is the administration workstation ?

Section titled “What if the host is the administration workstation ?”

During transport, nothing deploys any more : plan an alternate deployer. On arrival, it deploys the departure gateway through the VPN, then itself with just apply-local.

It takes away the host’s fixed address. Still plugged in, it would receive its gateway address when the lease renews, without the matching configuration, and the host name would no longer designate the address it occupies.

Yes, during transport the host is unreachable from both sides. It is expected by atelier from step 5 onwards and still monitored by maison until step 7. For a workstation, these are only warnings (see alert classes).

Restore the old zone, regenerate, then replay the procedure in reverse. Thanks to the gateway addresses, the host stays reachable in each zone in the meantime.