Commit e57b3f23 authored by Alex Hanselka's avatar Alex Hanselka
Browse files

feat: initial commit

parents
Pipeline #3255 passed with stage
in 4 minutes and 21 seconds
image: "alpine:latest"
stages:
- release
publish:
image: node:8
stage: release
before_script:
- npm install -g semantic-release @semantic-release/gitlab
script:
- semantic-release
only:
- master
verifyConditions:
- "@semantic-release/gitlab"
prepare: false
publish:
- "@semantic-release/gitlab"
success: false
fail: false
npmPublish: false
variable "node_name" {}
variable "image" {}
variable "type" {}
variable "ansible_groups" {
type = "list"
default = []
}
variable "hcloud_ansible_groups" {
type = "list"
default = ["hcloud"]
}
variable "ansible_token" {
description = "The pipeline token to trigger the ansible build"
type = "string"
}
data "google_dns_managed_zone" "darkdna" {
name = "darkdna"
}
# Create a new server running debian
resource "hcloud_server" "generic-hcloud" {
name = "${var.node_name}"
image = "${var.image}"
server_type = "${var.type}"
provisioner "local-exec" {
command = "curl -X POST -F token=${var.ansible_token} -F ref=master -F 'variables[NEW_HOST]=${var.node_name}' https://gitlab.darkdna.net/api/v4/projects/144/trigger/pipeline"
}
}
resource "ansible_host" "hcloud-host" {
inventory_hostname = "${hcloud_server.generic-hcloud.name}"
groups = "${concat(var.ansible_groups, var.hcloud_ansible_groups)}"
vars {
ansible_user = "root"
ansible_host = "${hcloud_server.generic-hcloud.ipv4_address}"
}
}
resource "google_dns_record_set" "external" {
name = "${var.node_name}.${data.google_dns_managed_zone.darkdna.dns_name}"
type = "A"
ttl = 3600
managed_zone = "${data.google_dns_managed_zone.darkdna.name}"
rrdatas = ["${hcloud_server.generic-hetzner.ipv4_address}"]
}
resource "google_dns_record_set" "external-v6" {
name = "${var.node_name}.${data.google_dns_managed_zone.darkdna.dns_name}"
type = "AAAA"
ttl = 3600
managed_zone = "${data.google_dns_managed_zone.darkdna.name}"
rrdatas = ["${hcloud_server.generic-hetzner.ipv6_address}"]
}
output "public_ip" {
value = "${hcloud_server.generic-hetzner.ipv4_address}"
}
output "public_ipv6" {
value = "${hcloud_server.generic-hetzner.ipv6_address}"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment