ansible vm deployment auf Proxmox - Disk groß ziehen

Mac_Leod

Captain
Registriert
Dez. 2001
Beiträge
3.867
Hi,

ich tu mich gerade etwas schwer im Partitionsvergrößern innerhalb eines „createvm“ playbooks.
Die betreffende vm ist ein ubuntu24 LTS im aktuellen Build.

Disk und Partitionen sehen so aus:

Code:
Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 151742A8-3DA5-4956-812D-EA36F0372343

Device Start End Sectors Size Type

/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 4198399 4194304 2G Linux filesystem
/dev/vda3 4198400 67108830 62910431 30G Linux filesystem --> hier drauf liegt dann LVM drauf

Situation:

Ich muss zu erst /dev/vda auf die maximale größe ziehen, was funktioniert.
Dann die Partition /dev/vda3
Dann, die darauf liegende PV, VG und LV. (jeweils einmal vorhanden).
Nur leider komme ich garnicht bis zum lvm Teil.

in dem Schritt wird nach dem clonen der VM die virtuelle disk großgezogen:

Code:
- name: Resize disk via Proxmox API
  community.general.proxmox_disk:
    api_host: "{{ proxmox.api_host }}"
    api_user: "{{ proxmox.api_user }}"
    api_password: "{{ proxmox.api_password }}"
    validate_certs: false
    vmid: "{{ proxmox.vmid }}"
    disk: "virtio0"
    size: "{{ vm.disk.size }}"
    state: resized
  delegate_to: localhost

das funktioniert auch, nur muss ich hinterher natürlich auch die Partitionen groß ziehen.
und hier bekomme ich die Meldungen im Ansible nicht abgefangen:
Code:
sudo parted /dev/vda resizepart 100%

Es geht dann um diese Meldungen, man muss meldungen interactive beantworten:

Code:
Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 142606336 blocks) or
continue with the current setting?
Fix/Ignore? Fix
Partition number?
Partition number? 3
End? [34.4GB]?

Wie geht man damit um? Geh ich das Thema evtl komplett falsch an? Ich hab kein passendes ansible Modul gefunden, was sich allein darum kümmert
 
Code:
$ parted --help
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE.  If no COMMAND(s) are given, run in
interactive mode.

OPTIONs:
  -h, --help                      displays this help message
  -l, --list                      lists partition layout on all block devices
  -m, --machine                   displays machine parseable output
  -j, --json                      displays JSON output
  -s, --script                    never prompts for user intervention
  -f, --fix                       in script mode, fix instead of abort when asked
  -v, --version                   displays the version
  -a, --align=[none|cyl|min|opt]  alignment for new partitions

siehe "-s"
Code:
-s, --script                    never prompts for user intervention

ansonsten ist das keyword zum suchen "non-interactive".
 
  • Gefällt mir
Reaktionen: nullx01
einer der Proxmox terraform provider konnte das.glaube der von bgp.

ansosnten quick'n dirty: https://forum.proxmox.com/threads/resize-disk-with-ansible.97892/#post-423198

Das Ansible modul habe ich nicht genutzt.

die Doku sieht das so:

Code:
- name: Grow existing disk
  community.general.proxmox_disk:
    api_host: node1
    api_user: root@pam
    api_token_id: token1
    api_token_secret: some-token-data
    vmid: 101
    disk: sata4
    size: +5G
    state: resized

du willst glaube ich die target size angeben, ich glaube, hier ist das Inkrement gefragt


dann das parted modul:
Code:
- name: Resize partition to use 100% of available space
  community.general.parted:
    device: /dev/vda
    number: 1
    state: present
    resize: true
    part_end: '100%'
 
  • Gefällt mir
Reaktionen: Mac_Leod
schau ich mir an, danke
 

Ähnliche Themen

Zurück
Oben