Skip to content

Instantly share code, notes, and snippets.

@moqmar
Forked from thetechnick/ignition.json
Created March 9, 2020 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moqmar/e62df19684ca7901e899b122bd9bc29c to your computer and use it in GitHub Desktop.
Save moqmar/e62df19684ca7901e899b122bd9bc29c to your computer and use it in GitHub Desktop.
Hetzner Cloud terraform coreos install
{
"ignition": {
"version": "2.0.0",
"config": {}
},
"storage": {
},
"systemd": {},
"networkd": {},
"passwd": {
"users": [
{
"name": "core",
"sshAuthorizedKeys": [
"<your public key>"
]
}
]
}
}
#!/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
provider "hcloud" {
token = "<token>"
}
resource "hcloud_ssh_key" "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_ssh_key.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_ssh_key.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}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment