mirror of
https://github.com/apricote/home-cloud.git
synced 2026-01-13 21:11:02 +00:00
bitwarden deployment
This commit is contained in:
commit
42ec743a00
24 changed files with 498 additions and 0 deletions
20
modules/docker_node/main.tf
Executable file
20
modules/docker_node/main.tf
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
resource "hcloud_server" "node" {
|
||||
name = "${var.name}"
|
||||
image = "${var.image}"
|
||||
server_type = "${var.server_type}"
|
||||
location = "${var.location}"
|
||||
|
||||
ssh_keys = ["${var.ssh_key_id}"]
|
||||
|
||||
connection {
|
||||
private_key = "${file("./keys/id_terraform")}"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
scripts = [
|
||||
"modules/docker_node/scripts/wait-cloud-init.sh",
|
||||
"modules/docker_node/scripts/install-docker.sh",
|
||||
"modules/docker_node/scripts/install-docker-compose.sh",
|
||||
]
|
||||
}
|
||||
}
|
||||
7
modules/docker_node/outputs.tf
Executable file
7
modules/docker_node/outputs.tf
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
output ip {
|
||||
value = "${hcloud_server.node.ipv4_address}"
|
||||
}
|
||||
|
||||
output id {
|
||||
value = "${hcloud_server.node.id}"
|
||||
}
|
||||
3
modules/docker_node/scripts/install-docker-compose.sh
Executable file
3
modules/docker_node/scripts/install-docker-compose.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
docker-compose --version
|
||||
28
modules/docker_node/scripts/install-docker.sh
Executable file
28
modules/docker_node/scripts/install-docker.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
# Source: https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository
|
||||
|
||||
echo "# apt-get update"
|
||||
apt-get update
|
||||
echo "# apt-get upgrade -y"
|
||||
DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' upgrade
|
||||
|
||||
# Add Repository
|
||||
echo "# apt-get install"
|
||||
apt-get install -y \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
software-properties-common
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||
add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
echo "# apt-get update"
|
||||
apt-get update
|
||||
|
||||
# Install Docker
|
||||
echo "# apt-get install docker-ce"
|
||||
apt-get install -y docker-ce
|
||||
13
modules/docker_node/scripts/wait-cloud-init.sh
Executable file
13
modules/docker_node/scripts/wait-cloud-init.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
# cloud-init is running at boot time and blocking access to apt.
|
||||
# Before doing anything we should wait for it to finish.
|
||||
# cloud-init creates a file after finishing boot.
|
||||
|
||||
echo "Waiting for cloud-init to finish provisioning the instance."
|
||||
while [ ! -f /var/lib/cloud/instance/boot-finished ]
|
||||
do
|
||||
echo "#"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Wait some more to be sure
|
||||
sleep 10
|
||||
22
modules/docker_node/vars.tf
Executable file
22
modules/docker_node/vars.tf
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
variable name {
|
||||
type = "string"
|
||||
}
|
||||
|
||||
variable image {
|
||||
type = "string"
|
||||
default = "ubuntu-18.04"
|
||||
}
|
||||
|
||||
variable server_type {
|
||||
type = "string"
|
||||
default = "cx11"
|
||||
}
|
||||
|
||||
variable location {
|
||||
type = "string"
|
||||
default = "nbg1"
|
||||
}
|
||||
|
||||
variable ssh_key_id {
|
||||
type = "string"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue