Commit 01afa95f authored by Alex Hanselka's avatar Alex Hanselka
Browse files

feat: pass in cloud-init data

parent 4588eb14
Pipeline #3288 passed with stage
in 4 minutes and 31 seconds
# Set Hostname
fqdn: ${server_hostname}.darkdna.net
# Install required packages for Ansible
packages:
- python-minimal
- python-setuptools
......@@ -2,11 +2,6 @@ variable "node_name" {}
variable "image" {}
variable "type" {}
variable "user_data" {
type = "string"
default = ""
}
variable "server_location" {
type = "string"
default = "nbg1"
......@@ -31,6 +26,26 @@ data "google_dns_managed_zone" "darkdna" {
name = "darkdna"
}
data "template_file" "init" {
template = "${file("${path.module}/data/cloud-init.tpl")}"
vars = {
server_hostname = "${var.node_name}"
}
}
data "template_cloudinit_config" "config" {
gzip = false
base64_encode = false
# Main cloud-config configuration file.
part {
filename = "init.cfg"
content_type = "text/cloud-config"
content = "${data.template_file.init.rendered}"
}
}
data "hcloud_ssh_key" "ansible" {
name = "scaleway-ansible"
}
......@@ -45,7 +60,7 @@ resource "hcloud_server" "generic-hcloud" {
server_type = "${var.type}"
location = "${var.server_location}"
ssh_keys = ["${data.hcloud_ssh_key.ansible.id}", "${data.hcloud_ssh_key.ahanselka.id}"]
user_data = "${var.user_data}"
user_data = "${data.template_cloudinit_config.config.rendered}"
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"
......
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