feat: cloudinit issues
This commit is contained in:
parent
2a2b98f3fe
commit
3326622634
3 changed files with 35 additions and 12 deletions
|
@ -23,27 +23,31 @@ in
|
||||||
{
|
{
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
|
|
||||||
#boot.loader.systemd-boot.enable = true;
|
# BOOT
|
||||||
#boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
|
||||||
# PROXMOX
|
# PROXMOX
|
||||||
services.qemuGuest.enable = true;
|
services.qemuGuest.enable = true;
|
||||||
services.cloud-init = {
|
services.cloud-init = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
network.enable = true;
|
||||||
};
|
};
|
||||||
|
environment.etc."cloud/cloud.cfg.d/99_pve.cfg".text = ''
|
||||||
|
datasource_list: [ NoCloud, ConfigDrive ]
|
||||||
|
'';
|
||||||
|
|
||||||
# USER MANAGEMENT
|
# USER MANAGEMENT
|
||||||
# TODO: Should this be in cloud-init?
|
# TODO: Should this be in cloud-init?
|
||||||
|
security.sudo.wheelNeedsPassword = false;
|
||||||
nix.settings.trusted-users = [ "nixos" ];
|
nix.settings.trusted-users = [ "nixos" ];
|
||||||
users.users.nixos = {
|
users.users.nixos = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
password = "nixos";
|
password = "hunter2";
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXAlzwziqfUUb2qmFwNF/nrBYc5MNT1MMOx81ohBmB+ tine@little.sys.tjo.space"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXAlzwziqfUUb2qmFwNF/nrBYc5MNT1MMOx81ohBmB+ tine@little.sys.tjo.space"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
security.sudo.wheelNeedsPassword = false;
|
|
||||||
|
|
||||||
# SSH
|
# SSH
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
|
@ -59,13 +63,18 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# FIREWALL
|
# FIREWALL
|
||||||
|
networking.useNetworkd = true;
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
trustedInterfaces = [ "tailscale0" ];
|
trustedInterfaces = [ "tailscale0" ];
|
||||||
|
|
||||||
allowedUDPPorts = [ config.services.tailscale.port ];
|
allowedUDPPorts = [ config.services.tailscale.port ];
|
||||||
allowedTCPPorts = [ 22 ];
|
allowedTCPPorts = [
|
||||||
|
22
|
||||||
|
80
|
||||||
|
443
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# NGINX
|
# NGINX
|
||||||
|
|
|
@ -47,7 +47,20 @@ resource "digitalocean_record" "internal" {
|
||||||
|
|
||||||
domain = data.digitalocean_domain.ingress.id
|
domain = data.digitalocean_domain.ingress.id
|
||||||
type = each.value.type
|
type = each.value.type
|
||||||
name = lower(each.value.node)
|
name = "internal.${lower(each.value.node)}"
|
||||||
value = each.value.ip
|
value = each.value.ip
|
||||||
ttl = 60
|
ttl = 60
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "digitalocean_record" "srv" {
|
||||||
|
for_each = local.nodes_with_address
|
||||||
|
|
||||||
|
domain = data.digitalocean_domain.ingress.id
|
||||||
|
type = "SRV"
|
||||||
|
name = digitalocean_record.internal[each.key].fqdn
|
||||||
|
value = "_nginx._tcp"
|
||||||
|
port = 9000
|
||||||
|
priority = 10
|
||||||
|
weight = 100
|
||||||
|
ttl = 60
|
||||||
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ locals {
|
||||||
nodes_with_address = {
|
nodes_with_address = {
|
||||||
for k, v in local.nodes :
|
for k, v in local.nodes :
|
||||||
k => merge(v, {
|
k => merge(v, {
|
||||||
public_ipv4 = local.ipv4_addresses[k]["eth0"][0]
|
public_ipv4 = local.ipv4_addresses[k]["ens18"][0]
|
||||||
public_ipv6 = local.ipv6_addresses[k]["eth0"][0]
|
public_ipv6 = local.ipv6_addresses[k]["ens18"][0]
|
||||||
internal_ipv4 = local.ipv4_addresses[k]["tailscale0"][0]
|
internal_ipv4 = local.ipv4_addresses[k]["tailscale0"][0]
|
||||||
internal_ipv6 = local.ipv6_addresses[k]["tailscale0"][0]
|
internal_ipv6 = local.ipv6_addresses[k]["tailscale0"][0]
|
||||||
})
|
})
|
||||||
|
@ -65,13 +65,14 @@ resource "proxmox_virtual_environment_file" "cloudinit" {
|
||||||
source_raw {
|
source_raw {
|
||||||
data = <<-EOF
|
data = <<-EOF
|
||||||
#cloud-config
|
#cloud-config
|
||||||
bootcmd:
|
runcmd:
|
||||||
|
- echo "hello world"
|
||||||
- [ 'tailscale', 'up', '--authkey', '${tailscale_tailnet_key.ingress.key}',
|
- [ 'tailscale', 'up', '--authkey', '${tailscale_tailnet_key.ingress.key}',
|
||||||
'--hostname', '${each.value.name}',
|
'--hostname', '${each.value.name}',
|
||||||
'--accept-routes', 'true',
|
'--accept-routes', 'true',
|
||||||
'--ssh' ]
|
'--ssh' ]
|
||||||
EOF
|
EOF
|
||||||
file_name = "${each.value.hostname}.cloudinit.yaml"
|
file_name = "${each.value.hostname}.cloudconfig.yaml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ resource "proxmox_virtual_environment_vm" "nodes" {
|
||||||
|
|
||||||
agent {
|
agent {
|
||||||
enabled = true
|
enabled = true
|
||||||
timeout = "1m"
|
timeout = "5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
network_device {
|
network_device {
|
||||||
|
@ -136,6 +137,6 @@ resource "proxmox_virtual_environment_vm" "nodes" {
|
||||||
|
|
||||||
initialization {
|
initialization {
|
||||||
datastore_id = each.value.storage
|
datastore_id = each.value.storage
|
||||||
meta_data_file_id = proxmox_virtual_environment_file.cloudinit[each.key].id
|
user_data_file_id = proxmox_virtual_environment_file.cloudinit[each.key].id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue