Ansible/playbook/infrastructure/containers/nextcloud/main.tf

157 lines
3.0 KiB
Terraform
Raw Normal View History

Dev (#9) * docker tests are looking good and nfs is able to connect and containers can talk to each other. * Added pihole support for a new vm * pihole is not working yet via docker. Installed it by hand without ansible for now. * added some docker related tasks and working on collins now to see how to use it. * forgot to push some changes... kube didnt work out as it adds too much overhead for what I need. * added two roles to help working with backup and restore of docker volume data. * did some cleanup on old roles. * pushing for axw testing * moving to requirements.yml. adding cron jobs for maint. * roles are being moved out of this repo. Roles are handled by requirements.yml going forward. Dev roles are still in the repo but if they stick around a new repo will be made for it. * Made a bunch of changes * fixed a problem * Added a playbook to deploy grafana and added prometheus role to monitor things. * Updated cron to test * Updated cron to test * Updated cron * updated discord_webhook and now testing if cron will pick up the changes. * Fixed plex backup for now. * docker updates and working on nginx * pushing pending changes that need to go live for cron testing * fixed debug roles and updated discord test * fixed debug roles and updated discord test * Disabling test cron * its been awhile... I am not sure what I have done anymore but time to push my changes. * added newsbot configs, added to jenkins, starting to migrate to collections. * Updated inventory to support the network changes * jenkinsfile is now working in my local setup. * node2 is unhealthy and is removed from inv. I was doing something to this box months ago, but now i dont remember what it was." * updated images and adding them to jenkins for testing * removed the old image files and moved to my public image * Jenkins will now inform discord of jobs. Added post tasks. Added mediaserver common. * updated the backend update job and adding a jenkins pipeline to handle it for me. * updated the backup job again * Updated all the jekins jobs. Added a jenkins newsbot backup job. Adjusted newsbot plays to add backup and redeploy jobs. * updated newsbot backup playbook to make older backup files as needed. * Added debug message to report in CI what version is getting deployed. * I did something stupid and this device is not letting me login for now. * removing twitter source for now as I found a bandwidth related bug that wont get pushed for a bit * Adding a bunch of changes, some is cleanup and some are adds * updated the images * updated the kube common playbook * Started to work on ceph, stopped due to hardware resources, updated common, added monit, and starting to work on a playbook to handle my ssh access. * Added a role to deploy monit to my servers. Still needs some more updates before its ready * Here is my work on ceph, it might go away but I am not sure yet. * Starting to migrate my common playbook to a role, not done yet. * updated kube and inventory * updated gitignore
2022-01-28 16:22:11 -08:00
provider "docker" {
host = "http://192.168.0.241:2375"
}
resource "docker_image" "nextcloud" {
name = "nextcloud:19.0.1-apache"
}
resource "docker_image" "postgres" {
name = "postgres:12.3"
}
resource "docker_image" "redis" {
name = "redis:6.0.6-alpine"
}
resource "docker_image" "proxy" {
name = "nginx:1.19.1-alpine"
}
resource "docker_volume" "nextcloud_web_data" {
name = "nextcloud_web_data"
}
resource "docker_volume" "nextcloud_db_data" {
name = "nextcloud_db_data"
}
resource "docker_network" "nextcloud" {
name = "nextcloud"
driver = "bridge"
ipam_config {
subnet = "172.200.0.0/16"
gateway = "172.200.0.1"
}
}
resource "docker_container" "nextcloud_proxy" {
count = 1
name = "nextcloud_proxy_${count.index}"
image = docker_image.proxy.latest
ports {
internal = 80
external = 80
}
upload {
file = "/etc/nginx/nginx.conf"
#content = file("nextcloud.conf")
content = <<EOF
events { }
http {
upstream nextcloud {
server ${docker_container.nextcloud_web.network_data.ip_address}:80;
}
server {
server_name example.local;
location / {
proxy_pass http://nextcloud_web_0:80;
}
location /nextcloud {
proxy_pass http://nextcloud;
}
}
EOF
}
networks_advanced {
name = docker_network.nextcloud.name
}
}
resource "docker_container" "nextcloud_cache" {
count = 1
name = "nextcloud_cache_${count.index}"
image = docker_image.redis.latest
ports {
internal = 6379
external = 6379
}
#env = ["value"]
networks_advanced {
name = docker_network.nextcloud.name
}
}
resource "docker_container" "nextcloud_db" {
count = 1
name = "nextcloud_db_${count.index}"
image = docker_image.postgres.latest
ports {
internal = 5432
external = 5432
}
volumes {
volume_name = docker_volume.nextcloud_db_data.name
container_path = "/var/lib/postgresql/data"
}
env = [
"POSTGRES_PASSWORD=password",
"POSTGRES_DB=nextcloud",
"POSTGRES_USER=nextcloudAdmin"
]
networks_advanced {
name = docker_network.nextcloud.name
#ipv4_address = "172.200.0.11"
}
}
resource "docker_container" "nextcloud_web" {
#count = 2
#name = "nextcloud_web_${count.index}"
name = "nextcloud_web_0"
image = docker_image.nextcloud.latest
ports {
internal = 80
#external = 8080
}
volumes {
volume_name = docker_volume.nextcloud_web_data.name
container_path = "/var/www/html"
}
env = [
"POSTGRES_DB=nextcloud",
"POSTGRES_USER=nextcloudAdmin",
"POSTGRES_PASSWORD=password",
"POSTGRES_HOST=nextcloud_db_0",
"REDIS_HOST=nextcloud_cache_1",
"REDIS_HOST_PORT=6379"
]
networks_advanced {
name = docker_network.nextcloud.name
#ipv4_address = "172.200.0.10"
}
}