Skip to content

Instantly share code, notes, and snippets.

@f4rx
Last active April 22, 2022 19:42
Show Gist options
  • Save f4rx/c135a784ea39ca1a5989838d5ba52a8e to your computer and use it in GitHub Desktop.
Save f4rx/c135a784ea39ca1a5989838d5ba52a8e to your computer and use it in GitHub Desktop.
2.modules
variable "server_count" {
  default = 1
}
resource "openstack_networking_port_v2" "port_1" {
  name       = "node-${count.index}-eth0"
  count      = var.server_count
...

resource "openstack_blockstorage_volume_v3" "volume_1" {
  name                 = "volume-for-node-${count.index}"
  count                = var.server_count
...

resource "openstack_compute_instance_v2" "instance_1" {
  name              = "node-${count.index}"
  count             = var.server_count
  network {
    port = openstack_networking_port_v2.port_1[count.index].id
  }

  block_device {
    uuid             = openstack_blockstorage_volume_v3.volume_1[count.index].id
...

create_server/output.tf

output "server_internal_ips" {
  value = openstack_compute_instance_v2.instance_1.*.access_ip_v4
}

outputs.tf

output "server_internal_ips" {
  value = module.server_remote_root_disk_1.server_internal_ips
}

Создать проект terraform_create_server в https://gitlab.slurm.io/projects/new

из корня create_server загрузить файлы в гитлаб

git init
git remote add origin [email protected]:s000150/terraform_create_server.git
git add .
git commit -m "Initial commit"
git push -u origin master
module "server_remote_root_disk_1" {
  source = "git::ssh://[email protected]/s000150/terraform_create_server.git?ref=master"
terraform init
terraform apply -var-file=./secrets.tfvars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment