Browse Source

start filling with life

main
Felix Kronlage-Dammers 3 months ago
commit
59e1e104dc
  1. 18
      .gitmodules
  2. 9
      LICENSE
  3. 27
      main.yml
  4. 1
      roles/ansible-debian-baseline
  5. 1
      roles/ansible-debian-nftables
  6. 1
      roles/ansible-debian-ntp
  7. 1
      roles/ansible-goneb-podman
  8. 1
      roles/ansible-nginx-letsencrypt
  9. 1
      roles/ansible-podman-host
  10. 166
      server.tf
  11. 9
      terraform.tfvars

18
.gitmodules vendored

@ -0,0 +1,18 @@
[submodule "roles/ansible-goneb-podman"]
path = roles/ansible-goneb-podman
url = https://g.hazardous.org/fkr/ansible-goneb-podman.git
[submodule "roles/ansible-debian-baseline"]
path = roles/ansible-debian-baseline
url = https://git.bitpack.io/sps/ansible-debian-baseline.git/
[submodule "roles/ansible-debian-ntp"]
path = roles/ansible-debian-ntp
url = https://git.bitpack.io/sps/ansible-debian-ntp.git/
[submodule "roles/ansible-podman-host"]
path = roles/ansible-podman-host
url = https://git.bitpack.io/sps/ansible-podman-host.git
[submodule "roles/ansible-nginx-letsencrypt"]
path = roles/ansible-nginx-letsencrypt
url = https://g.hazardous.org/fkr/ansible-nginx-letsencrypt.git
[submodule "roles/ansible-debian-nftables"]
path = roles/ansible-debian-nftables
url = https://g.hazardous.org/fkr/ansible-debian-nftables.git

9
LICENSE

@ -0,0 +1,9 @@
Copyright (c) 2022 Felix Kronlage-Dammers - All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

27
main.yml

@ -0,0 +1,27 @@
---
- hosts: all
vars:
nftables_tcp_dports: "22, 80, 443"
nginx_letsencrypt_email: "le@example.com"
nginx_hosts: [
{
default: true,
domain_name: "goneb.example.com",
reverse_hosts: [
{
protocol: "http",
path: "/",
host: "127.0.0.1",
port: "8443"
}
]
}
]
roles:
- ansible-debian-nftables
- ansible-debian-baseline
- ansible-debian-ntp
- ansible-podman-host
- ansible-globaleaks-podman
- ansible-nginx-letsencrypt

1
roles/ansible-debian-baseline

@ -0,0 +1 @@
Subproject commit 492e9961513237564e0ee4434d43db9385c001c9

1
roles/ansible-debian-nftables

@ -0,0 +1 @@
Subproject commit 235c37759681a4b757da8b58985f3514abe71429

1
roles/ansible-debian-ntp

@ -0,0 +1 @@
Subproject commit ee4b8019b87e35e8bbfb56c8908a957ff5e792a4

1
roles/ansible-goneb-podman

@ -0,0 +1 @@
Subproject commit a372551ec4cb5179b8b3973cd2e2eee0b1359056

1
roles/ansible-nginx-letsencrypt

@ -0,0 +1 @@
Subproject commit 5429c25c816b8e0414f45ca2eb3aa83dbc9bffe7

1
roles/ansible-podman-host

@ -0,0 +1 @@
Subproject commit ab99c15b2185b621228d02d17507b04e8a81eacd

166
server.tf

@ -0,0 +1,166 @@
terraform {
required_providers {
gridscale = {
source = "gridscale/gridscale"
}
dnsimple = {
source = "dnsimple/dnsimple"
version = "0.11.0"
}
}
}
provider "dnsimple" {
# Configuration options
token = "${var.dnsimple_token}"
account = "${var.dnsimple_account}"
}
variable "dnsimple_token" {
type = string
default = ""
}
variable "dnsimple_account" {
type = string
default = ""
}
variable "dnsimple_domain" {
type = string
default = "example.net"
}
variable "hostname_fqdn" {
type = string
default = "my-hostname.example.net"
}
variable "hostname" {
type = string
default = "my-hostname"
}
variable "hostname_alias" {
type = string
default = "my-hostname-alias"
}
variable "storage_name" {
type = string
default = var.hostname
}
variable "ip4_name" {
type = string
default = var.hostname +"_ip4"
}
variable "ip6_name" {
type = string
default = var.hostname +"_ip6"
}
variable "cores" {
type = number
default = 2
}
variable "memory" {
type = number
default = 4
}
variable "capacity" {
type = number
default = 20
}
variable "ansible_sshkey" {
type = string
default = ""
}
data "gridscale_public_network" "pubnet" {
}
resource "gridscale_server" "server" {
name = var.hostname_fqdn
cores = var.cores
memory = var.memory
power = true
ipv4 = gridscale_ipv4.ip.id
hardware_profile = "q35"
storage {
object_uuid = gridscale_storage.storage.id
}
network {
object_uuid = data.gridscale_public_network.pubnet.id
}
}
resource "gridscale_storage" "storage" {
name = var.storage_name
capacity = var.capacity
template {
template_uuid = data.gridscale_template.debian.id
hostname = var.hostname
sshkeys = [gridscale_sshkey.ssh_key.id]
}
}
resource "local_file" "ansible_inventory" {
content = "${gridscale_server.server.name} ansible_host=${gridscale_ipv4.ip.ip} ansible_user=root"
filename = "hosts"
file_permission = "0644"
}
resource "null_resource" "storage_provisioner" {
triggers = {
storage_id = gridscale_storage.storage.id
}
provisioner "remote-exec" {
inline = ["echo ${gridscale_server.server.id}"]
connection {
user = "root"
port = 22
host = gridscale_ipv4.ip.ip
timeout = "2m"
}
}
provisioner "local-exec" {
command = "ansible-playbook --ssh-common-args '-o StrictHostKeyChecking=no' --inventory hosts main.yml"
}
}
data "gridscale_template" "debian" {
name = "Debian 11"
}
resource "gridscale_sshkey" "ssh_key" {
name = "ed"
sshkey = var.ansible_sshkey
}
resource "gridscale_ipv4" "ip" {
name = var.ip4_name
}
output "server_ip" {
value = gridscale_ipv4.ip.ip
}
resource "dnsimple_zone_record" "foobar" {
zone_name = "${var.dnsimple_domain}"
name = var.hostname
value = gridscale_ipv4.ip.ip
type = "A"
ttl = 3600
}

9
terraform.tfvars

@ -0,0 +1,9 @@
cores = 2
memory = 4
capacity = 20
hostname_fqdn = "podman-host.example.com"
hostname = "podman-host"
ansible_sshkey = "<ssh key>"
dnsimple_token = "<dnsimple token>"
dnsimple_account = "<dnsimple account>"
dnsimple_domain = "example.com"
Loading…
Cancel
Save