This commit is contained in:
2023-07-04 19:02:30 +02:00
parent 04c1aa3086
commit 7cc046ea2a
41 changed files with 1401 additions and 4 deletions

View File

@ -0,0 +1,26 @@
%title: Terraform
%author: Hubert
# Terraform : remote_exec / SSH
<br>
* remote_exec > local_exec distant (ssh)
<br>
variable "host" {}
resource "null_resource" "ssh_target" {
connection {
type = "ssh"
user = var.ssh_user
host = var.ssh_host
private_key = file("/root/.ssh/id_rsa")
}
provisioner "remote-exec" {
inline = [
"sudo apt update -qq >/dev/null",
"sudo apt install -qq -y nginx >/dev/null"
]
}
}

View File

@ -0,0 +1,40 @@
variable "ssh_host" {}
variable "ssh_user" {}
variable "ssh_key" {}
resource "null_resource" "ssh_target" {
connection {
type = "ssh"
user = var.ssh_user
host = var.ssh_host
private_key = file(var.ssh_key)
}
provisioner "remote-exec" {
inline = [
"sudo apt update -qq >/dev/null",
"sudo apt install -qq -y nginx >/dev/null"
]
}
provisioner "file" {
source = "nginx.conf"
destination = "/tmp/default"
}
provisioner "remote-exec" {
inline = [
"sudo cp -a /tmp/default /etc/nginx/sites-available/default",
"sudo systemctl restart nginx"
]
}
provisioner "local-exec" {
command = "curl ${var.ssh_host}:667"
}
}
output "host" {
value = var.ssh_host
}
output "user" {
value = var.ssh_user
}
output "key" {
value = var.ssh_key
}

View File

@ -0,0 +1,16 @@
server {
listen 6666 default_server;
listen [::]:6666 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}