Le vendredi 03 février 2023 à 09:26 +0000, Pietro Pesce a écrit :
> Hi
>
> I'm new to using ansible, I'm writing a playbook to install a vm from
> template, everything works fine except for the disk names which stay
> the same as the template. The vm has more than one disk attached, I
> found this works for renaming the disk, but it only renames 1. how
> can I rename the others too?
>
> - name: Print vm attributes
> ovirt.ovirt.ovirt_vm_info:
> auth: "{{ ovirt_auth }}"
> pattern: name="{{ vm_fqdn }}"
> fetch_nested: true
> register: vm_info
> - debugging:
> msg: "{{ vm_info.ovirt_vms[0] }}"
>
>
> - name: Rename disk
> ovirt.ovirt.ovirt_disk:
> auth: "{{ ovirt_auth }}"
> id: "{{ vm_info.ovirt_vms[0].id }}"
> storage_domain: lrg0-ovirt-mydom-internal-Local
> name: "{{ vm_fqdn }}-osdisk0"
> vm_name: "{{ vm_fqdn }}"
What about trying (the disks can reside on different storage domains)
- name: get disk from vm
ovirt.ovirt.ovirt_disk_info:
auth: "{{ ovirt_auth }}"
pattern: vm_names="{{ vm_fqdn }}"
fetch_nested: yes
nested_attributes:
- name
register: result
- name: Rename disk
ovirt.ovirt.ovirt_disk:
auth: "{{ ovirt_auth }}"
id: "{{item.id}}"
# storage_domain: lrg0-ovirt-mydom-internal-Local
storage_domain: "{{item.storage_domains[0].name}}"
name: "{{ vm_fqdn }}-osdisk{{disk_number}}"
vm_name: "{{ vm_fqdn }}"
loop: "{{result.ovirt_disks}}"
loop_control:
label: "{{item}}"
index_var: disk_number
>
> Thanks
> Regards
> _______________________________________________
> Users mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> Privacy Statement: https://www.ovirt.org/privacy-policy.html
> oVirt Code of Conduct:
> https://www.ovirt.org/community/about/community-guidelines/
> List Archives:
> https://lists.ovirt.org/archives/list/[email protected]/message/QB7EHQS7PKX4IQUWOBQXEGJR5HENBD7T/
--
Nathanaël Blanchet
Administrateur Systèmes et Réseaux
Service Informatique et REseau (SIRE)
Département des systèmes d'information
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5
Tél. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
[email protected]
_______________________________________________
Users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct:
https://www.ovirt.org/community/about/community-guidelines/
List Archives:
https://lists.ovirt.org/archives/list/[email protected]/message/PCNBA6IZK2GLQKL4JRB6X3VWCFWECE7Z/