Skip to content

Instantly share code, notes, and snippets.

@thetechnick
Last active June 22, 2023 17:46
Show Gist options
  • Save thetechnick/12b33e4edfc96e4ccc9800afef2be7c5 to your computer and use it in GitHub Desktop.
Save thetechnick/12b33e4edfc96e4ccc9800afef2be7c5 to your computer and use it in GitHub Desktop.

Revisions

  1. thetechnick revised this gist Jun 21, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion main.tf
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ resource "hcloud_server" "master" {
    name = "master"
    image = "debian-9"
    server_type = "cx11"
    ssh_keys = ["${hcloud_sshkey.notebook.id}"]
    ssh_keys = ["${hcloud_ssh_key.notebook.id}"]
    datacenter = "fsn1-dc8"
    rescue = "linux64"

  2. thetechnick revised this gist May 24, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions main.tf
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ provider "hcloud" {
    token = "<token>"
    }

    resource "hcloud_sshkey" "notebook" {
    resource "hcloud_ssh_key" "notebook" {
    name = "nschieder@notebook"
    public_key = "${file("~/.ssh/id_ed25519.pub")}"
    }
    @@ -47,7 +47,7 @@ resource "hcloud_server" "node1" {
    name = "node1"
    image = "debian-9"
    server_type = "cx11"
    ssh_keys = ["${hcloud_sshkey.notebook.id}"]
    ssh_keys = ["${hcloud_ssh_key.notebook.id}"]
    datacenter = "fsn1-dc8"
    rescue = "linux64"

  3. thetechnick created this gist Jan 23, 2018.
    20 changes: 20 additions & 0 deletions ignition.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    {
    "ignition": {
    "version": "2.0.0",
    "config": {}
    },
    "storage": {
    },
    "systemd": {},
    "networkd": {},
    "passwd": {
    "users": [
    {
    "name": "core",
    "sshAuthorizedKeys": [
    "<your public key>"
    ]
    }
    ]
    }
    }
    8 changes: 8 additions & 0 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/usr/bin/env sh

    set -e

    wget https://raw.github.com/coreos/init/master/bin/coreos-install
    chmod +x coreos-install
    ./coreos-install -d /dev/sda -i /root/ignition.json
    reboot
    80 changes: 80 additions & 0 deletions main.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    provider "hcloud" {
    token = "<token>"
    }

    resource "hcloud_sshkey" "notebook" {
    name = "nschieder@notebook"
    public_key = "${file("~/.ssh/id_ed25519.pub")}"
    }

    resource "hcloud_server" "master" {
    name = "master"
    image = "debian-9"
    server_type = "cx11"
    ssh_keys = ["${hcloud_sshkey.notebook.id}"]
    datacenter = "fsn1-dc8"
    rescue = "linux64"

    connection {
    host = "${hcloud_server.master.ipv4_address}"
    timeout = "1m"
    agent = false
    private_key = "${file("~/.ssh/id_ed25519")}"
    }

    provisioner "file" {
    source = "ignition.json"
    destination = "/root/ignition.json"
    }

    provisioner "remote-exec" {
    script = "install.sh"
    }

    provisioner "remote-exec" {
    connection {
    host = "${hcloud_server.master.ipv4_address}"
    timeout = "1m"
    agent = false
    private_key = "${file("~/.ssh/id_ed25519")}"
    user = "core"
    }
    inline = "sudo hostnamectl set-hostname ${hcloud_server.master.name}"
    }
    }

    resource "hcloud_server" "node1" {
    name = "node1"
    image = "debian-9"
    server_type = "cx11"
    ssh_keys = ["${hcloud_sshkey.notebook.id}"]
    datacenter = "fsn1-dc8"
    rescue = "linux64"

    connection {
    host = "${hcloud_server.node1.ipv4_address}"
    timeout = "1m"
    agent = false
    private_key = "${file("~/.ssh/id_ed25519")}"
    }

    provisioner "file" {
    source = "ignition.json"
    destination = "/root/ignition.json"
    }

    provisioner "remote-exec" {
    script = "install.sh"
    }

    provisioner "remote-exec" {
    connection {
    host = "${hcloud_server.node1.ipv4_address}"
    timeout = "1m"
    agent = false
    private_key = "${file("~/.ssh/id_ed25519")}"
    user = "core"
    }
    inline = "sudo hostnamectl set-hostname ${hcloud_server.node1.name}"
    }
    }