Первая версия
This commit is contained in:
commit
0da0cfd3f9
9 changed files with 164 additions and 0 deletions
52
main.tf
Executable file
52
main.tf
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
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"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue