fix
This commit is contained in:
parent
2c7daea69f
commit
43491ed096
@ -38,7 +38,23 @@ module "compute" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module "iam" {
|
module "iam" {
|
||||||
source = "../../modules/iam"
|
source = "../../modules/iam"
|
||||||
|
|
||||||
project_id = var.project_id
|
project_id = var.project_id
|
||||||
|
}
|
||||||
|
|
||||||
|
data "google_client_openid_userinfo" "me" {
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "local_file" "ansible_config" {
|
||||||
|
content = templatefile("${path.module}/../../templates/ansible.cfg.tpl",
|
||||||
|
{
|
||||||
|
remote_user = data.google_client_openid_userinfo.me.email
|
||||||
|
}
|
||||||
|
)
|
||||||
|
filename = "../../ansible/ansible.cfg"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "local_file" "service_account" {
|
||||||
|
content = base64decode(module.iam.service_account_key)
|
||||||
|
filename = "../../ansible/service_account.json"
|
||||||
}
|
}
|
@ -1,39 +1,46 @@
|
|||||||
|
#- project_name (string)
|
||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
description = "Nom du projet"
|
description = "Nom du projet"
|
||||||
type = string
|
type = string
|
||||||
default = "newtp-443913"
|
default = "tp-1-docker"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#- project_id (string)
|
||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
description = "ID du projet"
|
description = "ID du projet"
|
||||||
type = string
|
type = string
|
||||||
default = "newtp-443913"
|
default = "tp-1-docker"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - region (string)
|
||||||
variable "region" {
|
variable "region" {
|
||||||
description = "Région du projet"
|
description = "Région du projet"
|
||||||
type = string
|
type = string
|
||||||
default = "europe-west4"
|
default = "europe-west4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - frontend_cidr (string)
|
||||||
variable "frontend_cidr" {
|
variable "frontend_cidr" {
|
||||||
description = "cidr du frontend"
|
description = "cidr du frontend"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.1.0/24"
|
default = "10.0.1.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - backend_cidr (string)
|
||||||
variable "backend_cidr" {
|
variable "backend_cidr" {
|
||||||
description = "cidr du backend"
|
description = "cidr du backend"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.2.0/24"
|
default = "10.0.2.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - database_cidr (string)
|
||||||
variable "database_cidr" {
|
variable "database_cidr" {
|
||||||
description = "cidr du database"
|
description = "cidr du database"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.3.0/24"
|
default = "10.0.3.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - ssh_source_ranges (string)
|
||||||
variable "ssh_source_ranges" {
|
variable "ssh_source_ranges" {
|
||||||
description = "Accès à internet"
|
description = "Accès à internet"
|
||||||
type = string
|
type = string
|
||||||
|
@ -36,6 +36,7 @@ resource "google_compute_instance" "backend" {
|
|||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
subnetwork = var.backend_subnet_id
|
subnetwork = var.backend_subnet_id
|
||||||
|
access_config {} # IP publique
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = ["backend", "ssh"]
|
tags = ["backend", "ssh"]
|
||||||
@ -59,8 +60,7 @@ resource "google_compute_instance" "database" {
|
|||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
subnetwork = var.database_subnet_id
|
subnetwork = var.database_subnet_id
|
||||||
access_config {}
|
access_config {} # IP publique
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = ["database", "ssh"]
|
tags = ["database", "ssh"]
|
||||||
|
@ -7,7 +7,7 @@ variable "instance_type" {
|
|||||||
variable "zone" {
|
variable "zone" {
|
||||||
description = "zone des instances"
|
description = "zone des instances"
|
||||||
type = string
|
type = string
|
||||||
default = "europe-west4-a"
|
default = "europe-west4"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "frontend_subnet_id" {
|
variable "frontend_subnet_id" {
|
||||||
|
@ -21,4 +21,4 @@ resource "google_os_login_ssh_public_key" "add_my_key" {
|
|||||||
project = var.project_id
|
project = var.project_id
|
||||||
user = data.google_client_openid_userinfo.me.email
|
user = data.google_client_openid_userinfo.me.email
|
||||||
key = file("~/.ssh/id_ed25519.pub")
|
key = file("~/.ssh/id_ed25519.pub")
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
# modules/iam/variables.tf
|
||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
description = "ID du projet GCP"
|
description = "ID du projet GCP"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
# VPC
|
||||||
resource "google_compute_network" "vpc" {
|
resource "google_compute_network" "vpc" {
|
||||||
name = "myvpc"
|
name = "myvpc"
|
||||||
auto_create_subnetworks = false
|
auto_create_subnetworks = false
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
|
#- project_name (string)
|
||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
description = "Nom du projet"
|
description = "Nom du projet"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
# - region (string)
|
||||||
variable "region" {
|
variable "region" {
|
||||||
description = "Région du projet"
|
description = "Région du projet"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
# - frontend_cidr (string)
|
||||||
variable "frontend_cidr" {
|
variable "frontend_cidr" {
|
||||||
description = "cidr du frontend"
|
description = "cidr du frontend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
# - backend_cidr (string)
|
||||||
variable "backend_cidr" {
|
variable "backend_cidr" {
|
||||||
description = "cidr du backend"
|
description = "cidr du backend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
# - database_cidr (string)
|
||||||
variable "database_cidr" {
|
variable "database_cidr" {
|
||||||
description = "cidr du database"
|
description = "cidr du database"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
# - ssh_source_ranges (string)
|
||||||
variable "ssh_source_ranges" {
|
variable "ssh_source_ranges" {
|
||||||
description = "Accès à internet"
|
description = "Accès à internet"
|
||||||
type = string
|
type = string
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
[defaults]
|
||||||
|
host_key_checking = False
|
||||||
|
inventory = gcp_compute.yml
|
||||||
|
interpreter_python = auto_silent
|
||||||
|
remote_user = ${replace(replace(remote_user, ".", "_"), "@", "_")}
|
||||||
|
|
||||||
|
[inventory]
|
||||||
|
enable_plugins = gcp_compute, auto, host_list, yaml, ini, toml, script
|
Loading…
Reference in New Issue
Block a user