main.tf 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. resource "linode_instance" "unifi-instance" {
  2. label = "${var.label}"
  3. region = "${var.region}"
  4. type = "${var.type}"
  5. image = "${var.image}"
  6. backups_enabled = true
  7. swap_size = 256
  8. authorized_keys = ["${chomp(file("~/.ssh/id_rsa.pub"))}"]
  9. provisioner "remote-exec" {
  10. inline = [
  11. "hostnamectl set-hostname ${var.label}",
  12. "echo '127.0.0.1 ${var.label}' >> /etc/hosts",
  13. "echo '::1 ${var.label}' >> /etc/hosts",
  14. ]
  15. }
  16. provisioner "file" {
  17. source = "${path.module}/files/etc/"
  18. destination = "/etc"
  19. }
  20. provisioner "remote-exec" {
  21. inline = [
  22. "chmod -R +x /etc/network/if-*.d/ip*",
  23. ]
  24. }
  25. provisioner "remote-exec" {
  26. inline = [
  27. "mkdir -p /tmp/scripts",
  28. ]
  29. }
  30. provisioner "file" {
  31. source = "${path.module}/scripts/"
  32. destination = "/tmp/scripts"
  33. }
  34. provisioner "remote-exec" {
  35. inline = [
  36. "chmod +x /tmp/scripts/*",
  37. "run-parts /tmp/scripts",
  38. ]
  39. }
  40. }