feat: provision ansible user with terraform #1
+4
-2
@@ -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}/templates/user_data.tpl", {
|
||||
ssh_public_key = var.ssh_public_key
|
||||
})
|
||||
firewall_ids = [hcloud_firewall.host.id]
|
||||
|
||||
public_net {
|
||||
@@ -76,7 +78,7 @@ resource "cloudflare_dns_record" "subdomain" {
|
||||
|
||||
# Write IP to Ansible inventory
|
||||
resource "local_file" "ansible_inventory" {
|
||||
content = templatefile("${path.module}/../ansible/inventory.tpl", {
|
||||
content = templatefile("${path.module}/templates/ansible_inventory.tpl", {
|
||||
public_ip = local.public_ip
|
||||
})
|
||||
filename = "${path.module}/../ansible/inventory.ini"
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user