# OpenStack Provider Configuration provider "openstack" { user_name = "" tenant_name = "" password = "" auth_url = "https://auth.pscloud.io/v3/" region = "kz-ala-1" } # Variables variable "centos_7_image" { default = "22e935a1-dffe-43d5-939f-98b5a2c92771" } variable "os_tenant_network" { default = "" } # Security Group Configuration resource "openstack_compute_keypair_v2" "keypair_name" { name = "keypair_name" public_key = "" } resource "openstack_compute_secgroup_v2" "sg_name" { name = "sg_name" description = "Security group for name" rule { from_port = 22 to_port = 22 ip_protocol = "tcp" cidr = "0.0.0.0/0" } rule { from_port = -1 to_port = -1 ip_protocol = "icmp" cidr = "0.0.0.0/0" } } # Block Storage Volumes resource "openstack_blockstorage_volume_v3" "volume_name_with_os" { name = "volume_name_with_os" description = "" size = 30 volume_type = "ceph-ssd" image_id = var.centos_7_image enable_online_resize = true } resource "openstack_blockstorage_volume_v3" "additional_volume_name" { name = "additional_volume_name" description = "" size = 100 volume_type = "ceph-ssd" enable_online_resize = true } # Compute Instance resource "openstack_compute_instance_v2" "instance_name" { name = "instance_name" flavor_name = "d1.ram4cpu1" key_pair = openstack_compute_keypair_v2.keypair_name.name security_groups = [openstack_compute_secgroup_v2.sg_name.name] config_drive = true user_data = <<-EOF #cloud-config password: your_password_here chpasswd: expire: false ssh_pwauth: true EOF block_device { uuid = openstack_blockstorage_volume_v3.volume_name_with_os.id source_type = "volume" boot_index = 0 destination_type = "volume" delete_on_termination = false } network { uuid = var.os_tenant_network fixed_ip_v4 = "10.0.0.155" } depends_on = [ openstack_compute_secgroup_v2.sg_name, openstack_blockstorage_volume_v3.volume_name_with_os ] } # Attach Additional Volume to Instance resource "openstack_compute_volume_attach_v2" "additional_volume_name" { instance_id = openstack_compute_instance_v2.instance_name.id volume_id = openstack_blockstorage_volume_v3.additional_volume_name.id depends_on = [ openstack_blockstorage_volume_v3.additional_volume_name ] }