1

I am trying to create autoinstall configuration for automatic ubuntu server installation and remote access. For remote access I would like to use Tailscale VPN. This example of my user-data file:

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  late-commands:
  - curl -fsSL https://tailscale.com/install.sh | sh
  - tailscale up --auth-key=${OAUTH_CLIENT_SECRET}?ephemeral=true --advertise-tags=tag:ci

This user-data configuration works. In the tailscale cabinet I am able to see new node established. So the late-commands works. But after restart I am not able to find tailscale program on the ubuntu and machine is not connected to the VPN anymore.

Why Tailscale is not available anymore and how to fix it? Is there alternatives to tailscale in installing ubuntu-server using autoinstall and remote ssh connection over internet?

1 Answer 1

1

Your commands are running in the installer environment instead of in the installed/target system. From the late-commands documentation

Shell commands to run after the install has completed successfully and any updates and packages installed, just before the system reboots. They are run in the installer environment

You can use the cloud-init installation method that you linked to in the comments with an autoinstall configuration like this.

#cloud-config
autoinstall:
  user-data:
    runcmd:
      # One-command install, from https://tailscale.com/download/
      - ['sh', '-c', 'curl -fsSL https://tailscale.com/install.sh | sh']
      # Set sysctl settings for IP forwarding (useful when configuring an exit node)
      - ['sh', '-c', "echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf && sudo sysctl -p /etc/sysctl.d/99-tailscale.conf" ]
      # Generate an auth key from your Admin console
      # https://login.tailscale.com/admin/settings/keys
      # and replace the placeholder below
      - ['tailscale', 'up', '--authkey=tskey-abcdef1432341818']
      # Optional: Include this line to make this node available over Tailscale SSH
      - ['tailscale', 'set', '--ssh']
      # Optional: Include this line to configure this machine as an exit node
      - ['tailscale', 'set', '--advertise-exit-node']

The installer will add the user-data content to the cloud-init configuration on the installed system. It will be visible in /etc/cloud/cloud.cfg.d/99-installer.cfg on the installed system.

9
  • Thx for reply. Tried at first only this command: - curtin in-target --target=/target -- curl -fsSL tailscale.com/install.sh | sh But still after restart got - tailscale: command not found. Commented Feb 25 at 12:24
  • @OlegKmechak I made a classic mistake where the command after the pipe is run in the installer environment. I updated the answer to avoid the piped command. Commented Feb 25 at 16:27
  • tailscale installed! Now facing problem with this: - curtin in-target --target=/target -- tailscale up --auth-key=${OAUTH_CLIENT_SECRET}?ephemeral=true --advertise-tags=tag:ci I think it requires, sudo. At least I tried to run just in ubuntu cmd and without sudo it wan't work. So, consequently I have tried next combindation: sudo curtin in-target --target=/target -- tailscale up --auth.... or curtin in-target --target=/target -- sudo tailscale up --auth.. . But same exit 1 error. Commented Feb 26 at 9:13
  • @OlegKmechak I don't know anything about tailscale but the tailscale up command certainly sounds like something that won't work in a chroot environment. Does it really need to be run during installation? What does it do during installation that is necessary? Commented Feb 26 at 23:08
  • I want to setup Ubuntu with remote access. Tailscale VPN is one of the options which I know best. It also comes with ssh. Btw figured out partially problem is that I should use not tailscale but /usr/bin/tailscale and then also sudo. Which currently checking. Commented Feb 28 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .