@maksimer/setup-infra
v1.0.1
Published
CLI tool to create and manage Hetzner servers and GridPane sites
Readme
@maksimer/setup-infra
This CLI tool automates the creation of Hetzner Cloud servers, registers them with GridPane, provisions them, and then creates a WordPress site on the newly provisioned server.
It aims to streamline the initial infrastructure setup for WordPress sites on GridPane-managed Hetzner servers.
Prerequisites
- Node.js (v20 or newer).
- An active Hetzner Cloud account and an API token.
- An active GridPane account and an API token.
- An SSH private key. The corresponding public key(s) should be added to your Hetzner Cloud account.
Usage
Execute the tool using npx:
npx @maksimer/setup-infraThe tool will present an interactive menu to guide you through the process.
Configuration
Initial Setup
The CLI will interactively prompt you for the following required information:
- Hetzner API Token: Your API token from the Hetzner Cloud console.
- GridPane API Token: Your API token from your GridPane account.
- SSH Key Path: Path to your SSH private key (defaults to
~/.ssh/id_rsa).
Token Persistence
After entering your API tokens for the first time, you'll be prompted to save them for future use. Saved tokens are stored securely in ~/.config/hetzner-gridpane-cli/config.json and will be automatically used in subsequent runs.
Workflow
When you run the command, it will:
- Show Interactive Menu: Select "Create a new Hetzner server and GridPane site" to begin.
- Collect Configuration: Load saved tokens or prompt for new ones. The SSH key path will default to
~/.ssh/id_rsa.- Note: The tool will load ALL SSH keys from your Hetzner account, not just the one at the specified path.
- Gather Site Details:
- Ask for the domain name for your new site.
- Ask for the desired WordPress admin username and email.
- Confirm Plan: Display a summary of the server and site to be created and ask for confirmation.
- Execute:
- Create a Hetzner server (type: cpx21, location: hel1 Helsinki).
- The server will be automatically named with prefix "gp-htz-" followed by your domain prefix.
- Wait for SSH access to the new server.
- Register the server with GridPane and run the GridPane provisioning script via SSH.
- Wait for GridPane server provisioning to complete.
- Create the WordPress site on GridPane.
- Wait for the site to become active.
- Report Success: Display the details of the newly created server and site.
Post-Setup
After successful completion, you'll need to:
- Manually activate SSL in GridPane for your new site.
- Configure DNS to point to your new server's IP address.
Error Handling
The tool provides detailed error messages with API responses. All output is color-coded for clarity:
- Green: Success messages
- Red: Error messages
- Cyan: Information and prompts
