52 lines
1.1 KiB
HCL
Executable file
52 lines
1.1 KiB
HCL
Executable file
terraform {
|
|
required_providers {
|
|
beget = {
|
|
source = "tf.beget.com/beget/beget"
|
|
}
|
|
}
|
|
}
|
|
|
|
variable "beget_token" {
|
|
sensitive = true
|
|
type = string
|
|
description = "JWT токен для облачной инфраструктуры Beget"
|
|
}
|
|
|
|
provider "beget" {
|
|
token = var.beget_token
|
|
}
|
|
|
|
resource "beget_ssh_key" "devops" {
|
|
name = "Terraform key"
|
|
public_key = file("~/.ssh/id_rsa.pub")
|
|
}
|
|
|
|
data "beget_software" "ubuntu" {
|
|
slug = "ubuntu-24-04"
|
|
}
|
|
|
|
resource "beget_compute_instance" "test-server" {
|
|
name = "Test Server"
|
|
description = "Тестовый TF сервер"
|
|
hostname = "debian-test"
|
|
region = "ru1"
|
|
configuration = {
|
|
cpu = 1
|
|
ram_mb = 1*1024
|
|
disk_mb = 10 * 1024
|
|
cpu_class = "normal_cpu"
|
|
}
|
|
image = {
|
|
software = {
|
|
id = data.beget_software.ubuntu.id
|
|
}
|
|
}
|
|
access = {
|
|
ssh_keys = [beget_ssh_key.devops.id]
|
|
}
|
|
|
|
|
|
provisioner "local-exec" {
|
|
command = "sleep 15; ansible-playbook -i '${self.ip_address},' --private-key ~/.ssh/id_rsa playbook.yml"
|
|
}
|
|
}
|