|
- # gitea is a PITA to automate installation of, watch this pr for when it'll be
- # fully setup-able from the cli https://github.com/go-gitea/gitea/issues/9210
- variable "gitea_db_passwd" {
- type = string
- }
-
- variable "cloudflare_functionalidiot_zoneid" {
- type = string
- }
-
- resource "cloudflare_record" "www" {
- depends_on = [
- cloudflare_record.root,
- cloudflare_record.splat ]
- zone_id = var.cloudflare_functionalidiot_zoneid
- name = "www"
- value = "functionalidiot.com"
- type = "CNAME"
- ttl = 1
- proxied = true
- }
-
- resource "cloudflare_record" "root" {
- depends_on = [
- linode_instance.prod,
- cloudflare_record.functionalidiot_com_ns1,
- cloudflare_record.functionalidiot_com_ns2 ]
- zone_id = var.cloudflare_functionalidiot_zoneid
- name = "@"
- value = linode_instance.prod.ip_address
- type = "A"
- ttl = 1
- proxied = true
- }
-
- resource "cloudflare_record" "splat" {
- depends_on = [
- linode_instance.prod,
- cloudflare_record.functionalidiot_com_ns1,
- cloudflare_record.functionalidiot_com_ns2 ]
- zone_id = var.cloudflare_functionalidiot_zoneid
- name = "*"
- value = linode_instance.prod.ip_address
- type = "A"
- ttl = 1
- proxied = true
- }
-
- resource "cloudflare_record" "functionalidiot_com_ns1" {
- zone_id = var.cloudflare_functionalidiot_zoneid
- name = "@"
- value = "mitch.ns.cloudflare.com"
- type = "NS"
- }
-
- resource "cloudflare_record" "functionalidiot_com_ns2" {
- zone_id = var.cloudflare_functionalidiot_zoneid
- name = "@"
- value = "tegan.ns.cloudflare.com"
- type = "NS"
- }
-
- resource "null_resource" "functionalidiot_com_setup" {
- depends_on = [ null_resource.post_setup ]
- connection {
- host = linode_instance.prod.ip_address
- user = "root"
- private_key = file("~/.ssh/id_rsa")
- }
- provisioner "file" {
- source = "setup_gitea.sh"
- destination = "/tmp/setup_gitea.sh"
- }
- provisioner "remote-exec" {
- inline = [<<FIN
- install -m755 /tmp/setup_gitea.sh /usr/local/bin/setup_gitea
- rm /tmp/setup_gitea.sh
- apk add gitea
- rc-update add gitea default
- skey=$(su - gitea -c "gitea generate secret SECRET_KEY")
- itoken=$(su - gitea -c "gitea generate secret INTERNAL_TOKEN")
- SECRET_KEY=$skey INTERNAL_TOKEN=$itoken /usr/local/bin/setup_gitea
- chown gitea:www-data /var/lib/gitea/db/gitea.db
- rc-service gitea restart
- su - gitea -c "gitea migrate --config /etc/gitea/app.ini"
- su - gitea -c "gitea admin create-user --username test --password test --email spam@whatever.mitchty.com --config /etc/gitea/app.ini"
- su - gitea -c "gitea admin create-user --username mitch --password ${var.gitea_db_passwd} --email spam@mitchty.com --admin --config /etc/gitea/app.ini"
- FIN
- ]
- }
- }
|