ansible-role-proxmox_vm_tools/tasks/resize_disk.yml

41 lines
1.1 KiB
YAML

- name: Agrandit le disque {{ item.disk }} de {{ item.size }}
uri:
url: "https://{{ pvmt_api_host }}:8006/api2/json/nodes/{{ pvmt_node }}/qemu/{{ pvmt_vm_id }}/resize"
validate_certs: no
method: PUT
headers:
Authorization: PVEAPIToken={{ pvmt_api_user }}!{{ pvmt_api_token_id }}={{ pvmt_api_token_secret }}
body_format: form-urlencoded
body:
disk: "{{ item.disk }}"
size: "{{ item.size }}"
- name: Attend l'application du changement
wait_for:
timeout: 2
- name: Agrandit le PV {{ item.pvuuid }}
shell: |
set -x
# detection de la nouvelle taille des disques
for i in `ls /sys/class/block/*/device/rescan`; do echo 1 > $i; done
PV=$(pvs -v | grep {{ item.pvuuid }} | awk '{ print $1 }')
if [ '{{ item.encrypted }}' = 'true' ]
then
echo "$PV est chiffre, agrandissement du disque chiffre"
cryptsetup resize $PV
fi
echo "Agrandissement du PV"
pvresize $PV
register: _shell_result
delegate_to: "{{ pvmt_vm_ip }}"
- debug:
var: _shell_result.stdout_lines
- debug:
var: _shell_result.stderr_lines