Automation and setup for sites I own.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

92 lines
2.7 KiB

  1. # gitea is a PITA to automate installation of, watch this pr for when it'll be
  2. # fully setup-able from the cli https://github.com/go-gitea/gitea/issues/9210
  3. variable "gitea_db_passwd" {
  4. type = string
  5. }
  6. variable "cloudflare_functionalidiot_zoneid" {
  7. type = string
  8. }
  9. resource "cloudflare_record" "www" {
  10. depends_on = [
  11. cloudflare_record.root,
  12. cloudflare_record.splat ]
  13. zone_id = var.cloudflare_functionalidiot_zoneid
  14. name = "www"
  15. value = "functionalidiot.com"
  16. type = "CNAME"
  17. ttl = 1
  18. proxied = true
  19. }
  20. resource "cloudflare_record" "root" {
  21. depends_on = [
  22. linode_instance.prod,
  23. cloudflare_record.functionalidiot_com_ns1,
  24. cloudflare_record.functionalidiot_com_ns2 ]
  25. zone_id = var.cloudflare_functionalidiot_zoneid
  26. name = "@"
  27. value = linode_instance.prod.ip_address
  28. type = "A"
  29. ttl = 1
  30. proxied = true
  31. }
  32. resource "cloudflare_record" "splat" {
  33. depends_on = [
  34. linode_instance.prod,
  35. cloudflare_record.functionalidiot_com_ns1,
  36. cloudflare_record.functionalidiot_com_ns2 ]
  37. zone_id = var.cloudflare_functionalidiot_zoneid
  38. name = "*"
  39. value = linode_instance.prod.ip_address
  40. type = "A"
  41. ttl = 1
  42. proxied = true
  43. }
  44. resource "cloudflare_record" "functionalidiot_com_ns1" {
  45. zone_id = var.cloudflare_functionalidiot_zoneid
  46. name = "@"
  47. value = "mitch.ns.cloudflare.com"
  48. type = "NS"
  49. }
  50. resource "cloudflare_record" "functionalidiot_com_ns2" {
  51. zone_id = var.cloudflare_functionalidiot_zoneid
  52. name = "@"
  53. value = "tegan.ns.cloudflare.com"
  54. type = "NS"
  55. }
  56. resource "null_resource" "functionalidiot_com_setup" {
  57. depends_on = [ null_resource.post_setup ]
  58. connection {
  59. host = linode_instance.prod.ip_address
  60. user = "root"
  61. private_key = file("~/.ssh/id_rsa")
  62. }
  63. provisioner "file" {
  64. source = "setup_gitea.sh"
  65. destination = "/tmp/setup_gitea.sh"
  66. }
  67. provisioner "remote-exec" {
  68. inline = [<<FIN
  69. install -m755 /tmp/setup_gitea.sh /usr/local/bin/setup_gitea
  70. rm /tmp/setup_gitea.sh
  71. apk add gitea
  72. rc-update add gitea default
  73. skey=$(su - gitea -c "gitea generate secret SECRET_KEY")
  74. itoken=$(su - gitea -c "gitea generate secret INTERNAL_TOKEN")
  75. SECRET_KEY=$skey INTERNAL_TOKEN=$itoken /usr/local/bin/setup_gitea
  76. chown gitea:www-data /var/lib/gitea/db/gitea.db
  77. rc-service gitea restart
  78. su - gitea -c "gitea migrate --config /etc/gitea/app.ini"
  79. su - gitea -c "gitea admin create-user --username test --password test --email spam@whatever.mitchty.com --config /etc/gitea/app.ini"
  80. su - gitea -c "gitea admin create-user --username mitch --password ${var.gitea_db_passwd} --email spam@mitchty.com --admin --config /etc/gitea/app.ini"
  81. FIN
  82. ]
  83. }
  84. }