diff --git a/master_nodes.tf b/master_nodes.tf index 0ce3a29..83c2edf 100644 --- a/master_nodes.tf +++ b/master_nodes.tf @@ -42,6 +42,8 @@ resource "proxmox_vm_qemu" "k3s-master" { sockets = local.master_node_settings.sockets memory = local.master_node_settings.memory + agent = 1 + disk { type = local.master_node_settings.storage_type storage = local.master_node_settings.storage_id @@ -59,6 +61,14 @@ resource "proxmox_vm_qemu" "k3s-master" { tag = local.master_node_settings.network_tag } + lifecycle { + ignore_changes = [ + ciuser, + sshkeys, + disk, + network + ] + } os_type = "cloud-init" @@ -68,6 +78,8 @@ resource "proxmox_vm_qemu" "k3s-master" { sshkeys = file(var.authorized_keys_file) + nameserver = var.nameserver + connection { type = "ssh" user = local.master_node_settings.user @@ -89,6 +101,8 @@ resource "proxmox_vm_qemu" "k3s-master" { user = "k3s" password = random_password.k3s-master-db-password.result }] + + http_proxy = var.http_proxy }) ] } diff --git a/scripts/install-k3s-server.sh.tftpl b/scripts/install-k3s-server.sh.tftpl index c3ceebd..91c3721 100644 --- a/scripts/install-k3s-server.sh.tftpl +++ b/scripts/install-k3s-server.sh.tftpl @@ -1,3 +1,8 @@ +export HTTP_PROXY="${http_proxy}" +export HTTPS_PROXY="${http_proxy}" +export http_proxy="${http_proxy}" +export https_proxy="${http_proxy}" + curl -sfL https://get.k3s.io | sh -s - ${mode} \ %{ for component in disable ~} --disable ${component} \ diff --git a/scripts/install-support-apps.sh.tftpl b/scripts/install-support-apps.sh.tftpl index 6fb7c92..e052c94 100644 --- a/scripts/install-support-apps.sh.tftpl +++ b/scripts/install-support-apps.sh.tftpl @@ -5,8 +5,13 @@ MARIADB_K3S_DATABASE="${k3s_database}" MARIADB_K3S_USER="${k3s_user}" MARIADB_K3S_PASSWORD="${k3s_password}" +export HTTP_PROXY="${http_proxy}" +export HTTPS_PROXY="${http_proxy}" +export http_proxy="${http_proxy}" +export https_proxy="${http_proxy}" + mariadb() { - sudo apt install mariadb-server -y + sudo -E apt install mariadb-server -y # Make mariadb listen to all remote requests sudo sed -i -e 's/\(bind-address\s*=\s*\)[0-9.]*/\10.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf @@ -28,7 +33,7 @@ mariadb() { } nginx() { - sudo apt install nginx -y + sudo -E apt install nginx -y } mariadb diff --git a/support_node.tf b/support_node.tf index 50a9612..e9c3546 100644 --- a/support_node.tf +++ b/support_node.tf @@ -14,9 +14,13 @@ locals { user = "support" network_tag = -1 + + db_name = "k3s" db_user = "k3s" + + network_bridge = "vmbr0" }) @@ -40,6 +44,8 @@ resource "proxmox_vm_qemu" "k3s-support" { sockets = local.support_node_settings.sockets memory = local.support_node_settings.memory + + agent = 1 disk { type = local.support_node_settings.storage_type storage = local.support_node_settings.storage_id @@ -57,6 +63,14 @@ resource "proxmox_vm_qemu" "k3s-support" { tag = local.support_node_settings.network_tag } + lifecycle { + ignore_changes = [ + ciuser, + sshkeys, + disk, + network + ] + } os_type = "cloud-init" @@ -66,6 +80,8 @@ resource "proxmox_vm_qemu" "k3s-support" { sshkeys = file(var.authorized_keys_file) + nameserver = var.nameserver + connection { type = "ssh" user = local.support_node_settings.user @@ -80,6 +96,8 @@ resource "proxmox_vm_qemu" "k3s-support" { k3s_database = local.support_node_settings.db_name k3s_user = local.support_node_settings.db_user k3s_password = random_password.k3s-master-db-password.result + + http_proxy = var.http_proxy }) } diff --git a/variables.tf b/variables.tf index 37dc6e2..789d365 100644 --- a/variables.tf +++ b/variables.tf @@ -131,3 +131,16 @@ variable "k3s_disable_components" { type = list(string) default = [] } + + +variable "http_proxy" { + default = "" + type = string + description = "http_proxy" +} + +variable "nameserver" { + default = "" + type = string + description = "nameserver" +} \ No newline at end of file diff --git a/worker_nodes.tf b/worker_nodes.tf index 4f832de..7523487 100644 --- a/worker_nodes.tf +++ b/worker_nodes.tf @@ -52,6 +52,8 @@ resource "proxmox_vm_qemu" "k3s-worker" { sockets = each.value.sockets memory = each.value.memory + agent = 1 + disk { type = each.value.storage_type storage = each.value.storage_id @@ -69,6 +71,15 @@ resource "proxmox_vm_qemu" "k3s-worker" { tag = each.value.network_tag } + lifecycle { + ignore_changes = [ + ciuser, + sshkeys, + disk, + network + ] + } + os_type = "cloud-init" ciuser = each.value.user @@ -77,6 +88,8 @@ resource "proxmox_vm_qemu" "k3s-worker" { sshkeys = file(var.authorized_keys_file) + nameserver = var.nameserver + connection { type = "ssh" user = each.value.user @@ -93,6 +106,8 @@ resource "proxmox_vm_qemu" "k3s-worker" { server_hosts = ["https://${local.support_node_ip}:6443"] node_taints = each.value.taints datastores = [] + + http_proxy = var.http_proxy }) ] }