Add contabo provider
This commit is contained in:
		
							parent
							
								
									ed555418e2
								
							
						
					
					
						commit
						048ea26034
					
				
					 10 changed files with 73 additions and 15 deletions
				
			
		
							
								
								
									
										23
									
								
								.terraform.lock.hcl
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										23
									
								
								.terraform.lock.hcl
									
										
									
										generated
									
									
									
								
							|  | @ -1,6 +1,29 @@ | ||||||
| # This file is maintained automatically by "tofu init". | # This file is maintained automatically by "tofu init". | ||||||
| # Manual edits may be lost in future updates. | # Manual edits may be lost in future updates. | ||||||
| 
 | 
 | ||||||
|  | provider "registry.opentofu.org/contabo/contabo" { | ||||||
|  |   version     = "0.1.26" | ||||||
|  |   constraints = "~> 0.1.26" | ||||||
|  |   hashes = [ | ||||||
|  |     "h1:BfyKQiCyA0w/UY1ZN07u9bKDi3y9tbLaj30AsmwhPS4=", | ||||||
|  |     "zh:13599dd31f62369779bcfc937c68a0fa0b3c865e9cfd805f204f78f995bd78b9", | ||||||
|  |     "zh:19bcf3660ac7545103cf999e0066442f9d6350db9654e1496726520cef287246", | ||||||
|  |     "zh:35d60f0e7f69cf87cca2451cfb7dd5a5a8a49663f08a114895da08fd86394412", | ||||||
|  |     "zh:3d993f0dc113982a7b2c2fdb6828bed9738631cf3c1e94cd8ad2a7ecd7a806bd", | ||||||
|  |     "zh:4aab2991ef6b81a5e6bc63af8a6711319d8c47cf2d2fde63f161f2cf6df4aea2", | ||||||
|  |     "zh:5d01929898c6e04d99264d6dd58424311a6f17415d583c74cdafc52cecc672ce", | ||||||
|  |     "zh:607c4619d312d5b76f4350961f3f37811a2b84084f1bc5626e0887110d5f7345", | ||||||
|  |     "zh:60d429eadbdab2f4c55a943760a172332c9c095e5f368ed682709146372adbc4", | ||||||
|  |     "zh:6e6234f31ba1f023314fe87b008cadae01d53f1fc96061500d1b2aa51276daef", | ||||||
|  |     "zh:7438d416c7f15b4484942bbce11b6f06b8c035b2dfd6066abc9fd92b50c655de", | ||||||
|  |     "zh:7a077cbcf5761e5ef55cb4202f97399da4ee9dfd2c5c32d05cf93b5351ef8aa9", | ||||||
|  |     "zh:91dbe0e31261e055f6af165a79cbf46e5712fcd1c80c24cf2d6ee2dfe60879f7", | ||||||
|  |     "zh:d7004852a590acfc299a273d02f22e5e7479ed40682adc65d28d2263a82168a9", | ||||||
|  |     "zh:f4b3a98be793845e886a4bbfdbe4d3dc833e151ba58c7807530d9c9fa9d19075", | ||||||
|  |     "zh:f69768aa6a33359ed22ad25eb8aca296086b8d65d2eff7e9b211c49aa2583f7d", | ||||||
|  |   ] | ||||||
|  | } | ||||||
|  | 
 | ||||||
| provider "registry.opentofu.org/cyrilgdn/postgresql" { | provider "registry.opentofu.org/cyrilgdn/postgresql" { | ||||||
|   version     = "1.23.0" |   version     = "1.23.0" | ||||||
|   constraints = "~> 1.23" |   constraints = "~> 1.23" | ||||||
|  |  | ||||||
|  | @ -10,8 +10,6 @@ hosts = { | ||||||
|     hostname = "node002" |     hostname = "node002" | ||||||
|     rdns = "node002.serguzim.net" |     rdns = "node002.serguzim.net" | ||||||
|     provider = "contabo" |     provider = "contabo" | ||||||
|     ipv4_address = "62.171.181.192" |  | ||||||
|     ipv6_address = "2a02:c207:2036:6681::1" |  | ||||||
|   }, |   }, | ||||||
|   "node003" = { |   "node003" = { | ||||||
|     hostname = "node003" |     hostname = "node003" | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								main.tf
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								main.tf
									
										
									
									
									
								
							|  | @ -35,6 +35,8 @@ module "services" { | ||||||
| module "infrastructure" { | module "infrastructure" { | ||||||
|   source = "./modules/infrastructure" |   source = "./modules/infrastructure" | ||||||
| 
 | 
 | ||||||
|  |   contabo_provider_vars = var.contabo_provider_vars | ||||||
|  | 
 | ||||||
|   hcloud_token = var.hcloud_token |   hcloud_token = var.hcloud_token | ||||||
| 
 | 
 | ||||||
|   ovh_application_key = var.ovh_application_key |   ovh_application_key = var.ovh_application_key | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								modules/infrastructure/contabo.tf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								modules/infrastructure/contabo.tf
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | resource "contabo_instance" "nodes" { | ||||||
|  |   for_each      = local.contabo_hosts | ||||||
|  |   display_name  = each.value.hostname | ||||||
|  | } | ||||||
|  | @ -12,10 +12,6 @@ data "template_file" "cloud_init" { | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| locals { |  | ||||||
|   hetzner_hosts = {for key, val in var.hosts : key => val if val.provider == "hetzner"} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| resource "hcloud_primary_ip" "node_ipv4_addresses" { | resource "hcloud_primary_ip" "node_ipv4_addresses" { | ||||||
|   for_each      = local.hetzner_hosts |   for_each      = local.hetzner_hosts | ||||||
|   name          = "primary_ipv4_${each.value.hostname}" |   name          = "primary_ipv4_${each.value.hostname}" | ||||||
|  |  | ||||||
|  | @ -1,5 +1,9 @@ | ||||||
| terraform { | terraform { | ||||||
|   required_providers { |   required_providers { | ||||||
|  |     contabo = { | ||||||
|  |       source = "contabo/contabo" | ||||||
|  |       version = "~> 0.1.26" | ||||||
|  |     } | ||||||
|     hcloud = { |     hcloud = { | ||||||
|       source = "hetznercloud/hcloud" |       source = "hetznercloud/hcloud" | ||||||
|       version = "~> 1.45.0" |       version = "~> 1.45.0" | ||||||
|  | @ -19,6 +23,12 @@ terraform { | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | provider "contabo" { | ||||||
|  |   oauth2_client_id     = var.contabo_provider_vars.client_id | ||||||
|  |   oauth2_client_secret = var.contabo_provider_vars.client_secret | ||||||
|  |   oauth2_user          = var.contabo_provider_vars.user | ||||||
|  |   oauth2_pass          = var.contabo_provider_vars.pass | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| provider "hcloud" { | provider "hcloud" { | ||||||
|   token = var.hcloud_token |   token = var.hcloud_token | ||||||
|  | @ -50,4 +60,7 @@ locals { | ||||||
|   services_auth = {for key, val in var.services : key => val if val.auth} |   services_auth = {for key, val in var.services : key => val if val.auth} | ||||||
|   services_database = {for key, val in var.services : key => val if val.database} |   services_database = {for key, val in var.services : key => val if val.database} | ||||||
|   services_s3 = {for key, val in var.services : key => val if val.s3} |   services_s3 = {for key, val in var.services : key => val if val.s3} | ||||||
|  | 
 | ||||||
|  |   contabo_hosts = {for key, val in var.hosts : key => val if val.provider == "contabo"} | ||||||
|  |   hetzner_hosts = {for key, val in var.hosts : key => val if val.provider == "hetzner"} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,12 +1,11 @@ | ||||||
| locals { | locals { | ||||||
|   contabo_hosts = {for key, val in var.hosts : key => val if val.provider == "contabo"} |  | ||||||
|   server_addresses = flatten([ |   server_addresses = flatten([ | ||||||
|     [ |     [ | ||||||
|       for host in local.contabo_hosts : [ |       for host in contabo_instance.nodes : [ | ||||||
|         { |         { | ||||||
|           hostname = host.hostname |           hostname = host.display_name | ||||||
|           ipv4_address = host.ipv4_address |           ipv4_address = host.ip_config[0].v4[0].ip | ||||||
|           ipv6_address = host.ipv6_address |           ipv6_address = host.ip_config[0].v6[0].ip | ||||||
|         }, |         }, | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|  |  | ||||||
|  | @ -1,3 +1,14 @@ | ||||||
|  | variable "contabo_provider_vars" { | ||||||
|  |   type = object({ | ||||||
|  |     client_id = string | ||||||
|  |     client_secret = string | ||||||
|  |     user = string | ||||||
|  |     pass = string | ||||||
|  |   }) | ||||||
|  |   sensitive = true | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| variable "hcloud_token" { | variable "hcloud_token" { | ||||||
|   sensitive = true |   sensitive = true | ||||||
| } | } | ||||||
|  | @ -66,8 +77,6 @@ variable "hosts" { | ||||||
|     hostname = string |     hostname = string | ||||||
|     rdns = string |     rdns = string | ||||||
|     provider = string |     provider = string | ||||||
|     ipv4_address = optional(string) |  | ||||||
|     ipv6_address = optional(string) |  | ||||||
|     image = optional(string) |     image = optional(string) | ||||||
|     server_type = optional(string) |     server_type = optional(string) | ||||||
|     datacenter = optional(string) |     datacenter = optional(string) | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								test.env
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								test.env
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | export CLIENT_ID="INT-335953" | ||||||
|  | export CLIENT_SECRET="19df6804-2a6a-40cd-a261-e3cd931cd550" | ||||||
|  | export API_USER="tobias@msrg.cc" | ||||||
|  | export API_PASSWORD="63ae822bee77a4dde9dc8bd6093c91c159f719d06c0a284c59bc08e9c48dd9eE+" | ||||||
|  | export ACCESS_TOKEN="eyJhbGciOiJSUzUxMiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIwMkt0QXpPSWtxYzFCdVdmNUI5T1BkSW1iQXRpXzN3VkV5RXV0VkNGbzQwIn0.eyJleHAiOjE3Mjc3MTg2OTcsImlhdCI6MTcyNzcxODM5NywianRpIjoiN2JiNTBjMTYtNWIyZi00YWIzLWFhYTUtY2ZkMjMyYTY4MTlmIiwiaXNzIjoiaHR0cHM6Ly9hdXRoLmNvbnRhYm8uY29tL2F1dGgvcmVhbG1zL2NvbnRhYm8iLCJzdWIiOiJjZTQ1ODI1MS1kMDE2LTQ0Y2YtYTBkNS00OWE0MWVkYTMyNjEiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJJTlQtMzM1OTUzIiwic2lkIjoiN2JiZDZmNjAtMDQ0ZS00YTgyLTllNjctMzM0OTk4YjE1N2FlIiwic2NvcGUiOiIiLCJvd25lciI6dHJ1ZSwiZW1haWxfdmVyaWZpZWQiOnRydWUsInJlc291cmNlUGVybWlzc2lvbnMiOiIiLCJhY2Nlc3NBbGxSZXNvdXJjZXMiOnRydWUsImN1c3RvbWVySWQiOiIzMzU5NTMiLCJ0ZW5hbnRJZCI6IklOVCIsImFkbWluIjp0cnVlLCJjdXJyZW5jeSI6IkVVUiIsInByZWZlcnJlZF91c2VybmFtZSI6InRvYmlhc0Btc3JnLmNjIiwibG9jYWxlIjoiZW4iLCJlbWFpbCI6InRvYmlhc0Btc3JnLmNjIiwiYXBpUGVybWlzc2lvbnMiOiIifQ.A-6IwdmV1L8HE8juiUf1gBA490yClYrNxk8rk7kwaCF2n7zYlP8S7EDjrv0x1Mc6Nzl1rwIMy08X56LuQAeMqyggLLKMVkcaG4d_En87kZMtnc6sou9OFoYA38Em7TcSMGln3okgyz6_Q01n26gbeZKptgFAwj5VIZNvBSEpPis7CLB3VBDkKuQkC5AK5cn3nKuiL2lzQZIOe1rXznL6EPDiPw-U1RenUoSrPthdmm58xUjFXddSTCGltHhNKbNZx0yTZhi3Erm7wJ8JjTt82DkD0gE5AajGnGXue9JisqVQf72HGcU8BVRXVpoloUH1SaPl3ZGsi-VdKIM4PrJgcT27btXm0tOvxP5xNAOa0aCEotM0PCnq2gA6QIzo_LIB-FHBzu30qeiGta2k15WVOnNYRH1EqzlD3ntx_SQrM5pOWwY6_OUk_dAYOiAq6c23GZQ8OnGUTV8yqNoEC_HTZFswVUwbxw9yBy_4QvWUDaqyI1a20LhRjkDpiATOMc32sjLgQf8FHjm7_YkcIHBv9MFzplzaOpic8T6R_k-ImEqCD6mgA8e6Wyyrw6OfTXYCVmCJZWfUNB01kjkEbNWCZB6o00NM7H0sq_arg-PvTMLyg7ov38xT_92i0q6wxuExpBJWASCbA-a20PaDkULsc5R72xonECesE29Ai8mLphk" | ||||||
							
								
								
									
										13
									
								
								variables.tf
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								variables.tf
									
										
									
									
									
								
							|  | @ -28,6 +28,17 @@ variable "authentik_token" { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | variable "contabo_provider_vars" { | ||||||
|  |   type = object({ | ||||||
|  |     client_id = string | ||||||
|  |     client_secret = string | ||||||
|  |     user = string | ||||||
|  |     pass = string | ||||||
|  |   }) | ||||||
|  |   sensitive = true | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| variable "hcloud_token" { | variable "hcloud_token" { | ||||||
|   sensitive = true |   sensitive = true | ||||||
| } | } | ||||||
|  | @ -117,8 +128,6 @@ variable "hosts" { | ||||||
|     hostname = string |     hostname = string | ||||||
|     rdns = string |     rdns = string | ||||||
|     provider = string |     provider = string | ||||||
|     ipv4_address = optional(string) |  | ||||||
|     ipv6_address = optional(string) |  | ||||||
|     image = optional(string) |     image = optional(string) | ||||||
|     server_type = optional(string) |     server_type = optional(string) | ||||||
|     datacenter = optional(string) |     datacenter = optional(string) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue