Skip to content

Instantly share code, notes, and snippets.

@yanndegat
Created April 4, 2018 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanndegat/8213ced1acf25d21f8340e363915884f to your computer and use it in GitHub Desktop.
Save yanndegat/8213ced1acf25d21f8340e363915884f to your computer and use it in GitHub Desktop.
attach vol is lost after resize
variable "flavor_name" {
default = "c2-7"
}
provider "openstack" {
region = "GRA3"
}
# Import Keypair
resource "openstack_compute_keypair_v2" "keypair" {
name = "trash-keypair"
public_key = "${file("~/.ssh/id_rsa.pub")}"
}
resource "openstack_networking_secgroup_v2" "sg" {
name = "trash_sg"
}
resource "openstack_networking_secgroup_rule_v2" "in_22_traffic" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
remote_ip_prefix = "0.0.0.0/0"
port_range_min = 22
port_range_max = 22
security_group_id = "${openstack_networking_secgroup_v2.sg.id}"
}
resource "openstack_blockstorage_volume_v2" "myvol" {
name = "myvol"
size = 5
}
data "openstack_images_image_v2" "debian7" {
name = "Debian 7"
most_recent = true
}
resource "openstack_compute_instance_v2" "test" {
name = "pci-1342"
flavor_name = "${var.flavor_name}"
image_id = "${data.openstack_images_image_v2.debian7.id}"
key_pair = "${openstack_compute_keypair_v2.keypair.name}"
security_groups = ["${openstack_networking_secgroup_v2.sg.name}"]
network {
name = "Ext-Net"
}
block_device {
uuid = "${data.openstack_images_image_v2.debian7.id}"
source_type = "image"
destination_type = "local"
boot_index = 0
delete_on_termination = true
}
block_device {
uuid = "${openstack_blockstorage_volume_v2.myvol.id}"
source_type = "volume"
destination_type = "volume"
boot_index = 1
delete_on_termination = true
}
}
output "public_ipv4" {
value = "ssh debian@${openstack_compute_instance_v2.test.access_ip_v4}"
}
source [openrc.sh]
terraform init
terraform apply -auto-approve
... ssh debian@...
... $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [245/884]
vda 254:0 0 5G 0 disk
sda 8:0 0 100G 0 disk
└─sda1 8:1 0 100G 0 part /
terraform apply -auto-approve -var flavor_name=c2-15
... ssh debian@...
... $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [245/884]
vda 254:0 0 5G 0 disk
sda 8:0 0 100G 0 disk
└─sda1 8:1 0 100G 0 part /
terraform destroy -auto-approve
@twillouer
Copy link

block_device {
boot_index = 1
delete_on_termination = true
destination_type = "volume"
source_type = "blank"
volume_size = "${var.volume_size_orchestrator}"
}

j'ai mis plein de données dans le vg02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment