diff options
| author | jerome <jerome@xlinfo.fr> | 2025-02-04 15:02:50 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-02-04 15:02:50 +0100 |
| commit | 2a485c2921146c76023e8dabbaa6d4bedee1aa7b (patch) | |
| tree | 926f6f658ddfcc3dec44702c76b70cc4dcd08ffd | |
| parent | 3b3f35127f2cfa7e08d943a0555c095ad553021f (diff) | |
| download | kvm-2a485c2921146c76023e8dabbaa6d4bedee1aa7b.tar.gz kvm-2a485c2921146c76023e8dabbaa6d4bedee1aa7b.zip | |
resize bse image
| -rw-r--r-- | cloud_init.cfg | 8 | ||||
| -rw-r--r-- | libvirt.tf | 17 | ||||
| -rw-r--r-- | terraform.tfvars | 12 |
3 files changed, 22 insertions, 15 deletions
diff --git a/cloud_init.cfg b/cloud_init.cfg index 1bd0db6..39dd4f6 100644 --- a/cloud_init.cfg +++ b/cloud_init.cfg @@ -4,7 +4,7 @@ manage_etc_hosts: true fqdn: ${nom} users: - - name: jerome + - name: ansible lock_passwd: false passwd: $6$HiJy.FDst/oZW34k$yY/T.VDsZJgI7o7kvbpRbLe7JLfyxAso6KPTb6TbqdHKCNE5fVq2.eJWxCP9QfsI/7rpluw9HKy7LHVSfLPdC0 ssh_authorized_keys: @@ -14,12 +14,12 @@ users: runcmd: - - cp /etc/skel/.* /home/jerome/ - - chown jerome:jerome /home/jerome/.* + - cp /etc/skel/.* /home/ansible/ + - chown ansible:ansible /home/ansible/.* - ${package} write_files: - - path: /home/jerome/helloworld + - path: /home/ansible/helloworld content: | #!/bin/bash echo "Hello World !" @@ -1,11 +1,18 @@ # Defining VM Volume -resource "libvirt_volume" "qcow2_vol" { - name = "${var.nom}.qcow2" +resource "libvirt_volume" "base" { + name = "${var.nom}-base" pool = "default" source = var.image format = "qcow2" } +resource "libvirt_volume" "image" { + name = "${var.nom}.qcow2" + base_volume_id = libvirt_volume.base.id + pool = "default" + size = 10 * 1024 * 1024 *1024 +} + # get user data info data "template_file" "user_data" { template = file("${path.module}/cloud_init.cfg") @@ -35,13 +42,13 @@ resource "libvirt_domain" "vm_domain" { } network_interface { - #network_name = "default" - bridge = "bridge0" + network_name = "default" + #bridge = "bridge0" wait_for_lease = true } disk { - volume_id = libvirt_volume.qcow2_vol.id + volume_id = libvirt_volume.image.id } cloudinit = libvirt_cloudinit_disk.commoninit.id diff --git a/terraform.tfvars b/terraform.tfvars index f8d043f..950a326 100644 --- a/terraform.tfvars +++ b/terraform.tfvars @@ -1,14 +1,14 @@ # Assignation des variables ########## machine rocky ########## -nom = "rocky" -image = "/home/jerome/Téléchargements/isos/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" +#nom = "rocky" +#image = "/home/jerome/Téléchargements/isos/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" #image = "https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" -package = "# rien à faire : qemu-guest-agent pré-installé" +#package = "# rien à faire : qemu-guest-agent pré-installé" ########## machine debian ########## -#nom = "debian" -#image = "/home/jerome/Téléchargements/isos/debian-12-generic-amd64.qcow2" +nom = "debian" +image = "/home/jerome/Téléchargements/isos/debian-12-generic-amd64.qcow2" #image = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2" -#package = "apt update && apt install -y qemu-guest-agent && systemctl start qemu-guest-agent" +package = "apt update && apt install -y qemu-guest-agent && systemctl start qemu-guest-agent" |
