users and nginx.conf, some vars too
This commit is contained in:
		
							parent
							
								
									844d29a51b
								
							
						
					
					
						commit
						64a777464c
					
				
					 3 changed files with 49 additions and 9 deletions
				
			
		
							
								
								
									
										22
									
								
								main.tf
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								main.tf
									
										
									
									
									
								
							| 
						 | 
					@ -16,7 +16,7 @@ resource "yandex_compute_instance" "vm" {
 | 
				
			||||||
  platform_id = "standard-v1"
 | 
					  platform_id = "standard-v1"
 | 
				
			||||||
  boot_disk {
 | 
					  boot_disk {
 | 
				
			||||||
    initialize_params {
 | 
					    initialize_params {
 | 
				
			||||||
      image_id = "fd8gp9bblb0vpvqtch1k" # lemp
 | 
					      image_id = "fd84am5rkt7hj8es82a5" # lemp
 | 
				
			||||||
      size = 5
 | 
					      size = 5
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -31,24 +31,20 @@ resource "yandex_compute_instance" "vm" {
 | 
				
			||||||
    cores = 2
 | 
					    cores = 2
 | 
				
			||||||
    memory = 2
 | 
					    memory = 2
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  metadata = { user-data = "${file("users.yml")}" }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
resource "yandex_vpc_network" "network-1" {
 | 
					resource "yandex_vpc_network" "network-1" {
 | 
				
			||||||
  name = "network-1"
 | 
					  name = "network-1"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
resource "yandex_vpc_subnet" "subnet-1" {
 | 
					resource "yandex_vpc_subnet" "subnet-1" {
 | 
				
			||||||
  name = "subnet-1"
 | 
					  name = "subnet-1"
 | 
				
			||||||
  v4_cidr_blocks = [ "172.24.8.0/24"]
 | 
					  v4_cidr_blocks = [ "172.24.8.0/24"]
 | 
				
			||||||
  network_id = yandex_vpc_network.network-1.id
 | 
					  network_id = yandex_vpc_network.network-1.id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
resource "yandex_lb_target_group" "demo-1" {
 | 
					resource "yandex_lb_target_group" "demo-1" {
 | 
				
			||||||
  name = "demo-1"
 | 
					  name = "demo-1"
 | 
				
			||||||
  target {
 | 
					  target {
 | 
				
			||||||
| 
						 | 
					@ -62,8 +58,6 @@ resource "yandex_lb_target_group" "demo-1" {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
resource "yandex_lb_network_load_balancer" "lb-1" {
 | 
					resource "yandex_lb_network_load_balancer" "lb-1" {
 | 
				
			||||||
  name = "lb-1"
 | 
					  name = "lb-1"
 | 
				
			||||||
  deletion_protection = "false"
 | 
					  deletion_protection = "false"
 | 
				
			||||||
| 
						 | 
					@ -86,3 +80,13 @@ resource "yandex_lb_network_load_balancer" "lb-1" {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "lb-ip" {
 | 
				
			||||||
 | 
					  value = yandex_lb_network_load_balancer.lb-1.listener
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "vm-ips" {
 | 
				
			||||||
 | 
					  value = tomap({
 | 
				
			||||||
 | 
					    for name, vm in yandex_compute_instance.vm : name => vm.network_interface.0.nat_ip_address
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										29
									
								
								nginx.conf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								nginx.conf
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					user www-data;
 | 
				
			||||||
 | 
					worker_processes auto;
 | 
				
			||||||
 | 
					pid /run/nginx.pid;
 | 
				
			||||||
 | 
					include /etc/nginx/modules-enabled/*.conf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					events {
 | 
				
			||||||
 | 
					        worker_connections 768;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					http {
 | 
				
			||||||
 | 
					        sendfile on;
 | 
				
			||||||
 | 
					        tcp_nopush on;
 | 
				
			||||||
 | 
					        tcp_nodelay on;
 | 
				
			||||||
 | 
					        keepalive_timeout 65;
 | 
				
			||||||
 | 
					        types_hash_max_size 2048;
 | 
				
			||||||
 | 
					        include /etc/nginx/mime.types;
 | 
				
			||||||
 | 
						default_type text/html;
 | 
				
			||||||
 | 
					        access_log /var/log/nginx/access.log;
 | 
				
			||||||
 | 
					        error_log /var/log/nginx/error.log;
 | 
				
			||||||
 | 
					        gzip on;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        server {
 | 
				
			||||||
 | 
					                listen 80 default_server;
 | 
				
			||||||
 | 
					                listen [::]:80 default_server;
 | 
				
			||||||
 | 
					                location / {
 | 
				
			||||||
 | 
					                        return 200 "My internal ip: $server_addr";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										7
									
								
								users.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								users.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					#cloud-config
 | 
				
			||||||
 | 
					users:
 | 
				
			||||||
 | 
					  - name: von
 | 
				
			||||||
 | 
					    shell: /bin/bash
 | 
				
			||||||
 | 
					    sudo: ALL=(ALL) NOPASSWD:ALL
 | 
				
			||||||
 | 
					    ssh-authorized-keys:
 | 
				
			||||||
 | 
					      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEt0hgwAMTEZNNQXn91s2dEj1R+jRR16qYQNZxZiAzD/ von@debian
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue