diff --git a/ansible/inventory.tpl b/ansible/inventory.tpl index 4946117..90880f2 100644 --- a/ansible/inventory.tpl +++ b/ansible/inventory.tpl @@ -1,2 +1,2 @@ [dokploy] -dokploy ansible_host=${public_ip} ansible_user=root +dokploy ansible_host=${public_ip} diff --git a/terraform/main.tf b/terraform/main.tf index 8850638..8036b6a 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -10,7 +10,9 @@ resource "hcloud_server" "dokploy" { image = var.hcloud_image server_type = var.hcloud_server_type location = var.hcloud_location - ssh_keys = [hcloud_ssh_key.ansible.id] + user_data = templatefile("${path.module}/user_data.tpl", { + ssh_public_key = var.ssh_public_key + }) firewall_ids = [hcloud_firewall.host.id] public_net { diff --git a/terraform/user_data.tpl b/terraform/user_data.tpl new file mode 100644 index 0000000..e9f97c2 --- /dev/null +++ b/terraform/user_data.tpl @@ -0,0 +1,9 @@ +# cloud-config +users: + - name: ansible + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + ssh_authorized_keys: + - ${ssh_public_key} +ssh_pwauth: false +disable_root: true