Skip to content

Configuration

Open the development shell, which includes all the tools needed:

nix develop

If your Initial controller Linux distribution is Ubuntu, you need to execute the following command:

# Install nix
sudo apt install -y nix

# Add your normal user to the nix* group
sudo usermod -aG nixbld $USER
sudo usermod -aG nix-users $USER

# Re-login to apply the changes
# You can also run the following command to activate the changes to groups:
newgrp nixbld      
newgrp nix-user

# nix develop
nix develop --extra-experimental-features nix-command --extra-experimental-features flakes

Run the following script to configure the homelab:

make configure

Example

Enter your env (prod):
Text editor (nvim):
Enter seed repo (github.com/east4ming/homelab2): github.com/example/homelab
Enter your domain (west-beta.ts.net): example.ts.net

It will prompt you to edit the inventory:

  • control_plane_endpoint
  • tailscale_auth_key
  • tailscale_client_id
  • tailscale_client_secret
  • registries_config_yaml
  • IP address: the desired one, not the current one, since your servers have no operating system installed yet
  • Disk: based on /dev/$DISK, in my case it's sda, but yours can be sdb, nvme0n1...
  • Network interface: usually it's eth0, mine is eno1
  • MAC address: the lowercase, colon separated MAC address of the above network interface

Example

metal/inventories/prod.yml
all:
  vars:
    control_plane_endpoint: 192.168.3.100
    load_balancer_ip_pool:
      - 192.168.3.32/27
    ntp_server: "ntp.ubuntu.com"
    # Used for tailscale k8s node
    tailscale_auth_key: "tskey-auth-..."
    # Used for tailscale-operator
    tailscale_client_id: "xxxxx"
    tailscale_client_secret: "tskey-client-..."
    # TODO:
    registries_config_yaml: |
      mirrors:
        "*":
        docker.io:
          endpoint:
            - "https://registry.cn-hangzhou.aliyuncs.com"
metal:
  children:
    masters:
      hosts:
        n100-jumper-0:
          ansible_host: 192.168.3.226
          mac: "00:e0:4c:72:37:9f"
          disk: nvme0n1
          network_interface: enp3s0
        n100-jumper-1:
          ansible_host: 192.168.3.174
          mac: "00:e0:4c:72:37:6b"
          disk: nvme0n1
          network_interface: enp3s0
        n100-jumper-2:
          ansible_host: 192.168.3.158
          mac: "00:e0:4c:72:37:5b"
          disk: nvme0n1
          network_interface: enp3s0
    workers:
      hosts:
        n100-cheshi-0:
          ansible_host: 192.168.3.154
          mac: "00:f0:4d:00:0c:7d"
          disk: nvme0n1
          network_interface: enp2s0

At the end it will show what has changed. After examining the diff, commit and ~~push~~ the changes.

🐾Warning: 不要将您的任何密钥 PUSH 到 GitHub 公共仓库. 包括不限于:

  • metal/inventories/prod.yml
  • tailscale_auth_key
  • tailscale_client_id
  • tailscale_client_secret
  • registries_config_yaml