I seem to have been able to overcome yaml problems, and I am able to successfully create Centos8 VMs with cloud-init.
My one remaining challenge is successfully renaming the VM disk alias, which fails with the error below.
Would really appreciate help with this.

My current playbook looks like what’s below,

---
- hosts: ovirt.ovirt.mydom.internal
  tasks:
    - import_tasks: ovirt_auth.yml

    - name: Creates new virtual machine
      ovirt.ovirt.ovirt_vm:
        auth: "{{ ovirt_auth }}"
        name: "{{ vm_fqdn }}"
        state: running
        clone: true
        cluster: lrg0-ovirt-cluster
        storage_domain: lrg0-ovirt-mydom-internal-Local
        template: template-test00-centos8
        type: server
        disk_format: raw
        nics:
          - name: eth0
            boot_protocol: dhcp
            interface: virtio
            profile_name: "{{ net_profile_name }}"
        graphical_console:
          protocol:
            - spice
            - vnc
        cloud_init:
          regenerate_ssh_keys: true
          host_name: "{{ vm_fqdn }}"
          user_name: mydomadmin
          root_password: <password>
          dns_search: services.mydom.internal mydom.internal
          dns_servers: 10.200.20.4 10.200.20.6
          custom_script: |
            write_files:
            - path: /tmp/setup.sh
              permissions: '0755'
              content: |
                #!/bin/bash
                echo "$(hostnamectl )" > /tmp/echos.txt
                ipa-client-install --hostname=$(hostname -f) \
                --server=ipa0.services.mydom.internal \
                --mkhomedir --domain=service.mydom.internal \
                --realm=SERVICES.mydom.INTERNAL --no-ntp \
                --principal=admin --password=<password> \
                --enable-dns-updates --unattended
                # auto-mount stuff
                cat << EOF >> /etc/auto.misc
                *       -rw,fstype=nfs  nfs1.services.mydom.internal:/share/&
                EOF
                sed -i 's/\/misc/\/share/' /etc/auto.master
                setsebool -P use_nfs_home_dirs on
                systemctl enable --now autofs
                systemctl start autofs
            runcmd:
            - [ /tmp/setup.sh, "{{ vm_fqdn }}" ]

    - name: Print vm attributes
      ovirt.ovirt.ovirt_vm_info:
        auth: "{{ ovirt_auth }}"
        pattern: name="{{ vm_fqdn }}"
      register: vm_info
    - debug:
        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 }}"


Error:

TASK [Rename disk] *********************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ovirtsdk4.Error: Fault reason is "Incomplete parameters". Fault detail is "Disk [provisionedSize] required for add". HTTP response code is 400.
[WARNING]: Module did not set no_log for pass_discard
fatal: [ovirt.ovirt.trove.internal]: FAILED! => {"changed": false, "msg": "Fault reason is \"Incomplete parameters\". Fault detail is \"Disk [provisionedSize] required for add\". HTTP response code is 400."}

PLAY RECAP ***************************************************************************************************************************************************************************** 


On 27 Nov 2021, at 23:38, Strahil Nikolov <hunter86_bg@yahoo.com> wrote:

Does it work when you remove the 'custom_script' section ?

Best Regards,
Strahil Nikolov

On Sat, Nov 27, 2021 at 7:35, Sina Owolabi
No errors at all
Same results again
Screenshot attached for a better view, but this is where it's at right now:
----
      sso: true
        disk_format: raw
        graphical_console:
          protocol:
            - spice
            - vnc
        cloud_init:
          regenerate_ssh_keys: true
          host_name: "{{ vm_fqdn }}"
          dns_search: mydom.internal
          dns_servers: <dns ip1> <dns ip2>
          custom_script: |
            write_files:
            - path: /tmp/setup.sh
              permissions: '0755'
              content: |
                #!/bin/bash
                echo "$(hostname -f)" >> /tmp/myhostname.txt
                ipa-client-install --hostname=`hostname -f` \
                --mkhomedir --domain=services.mydom.internal \
                --realm=SERVICES.MYDOM.INTERNAL  --no-ntp \
                --principal=admin --password=<password> \
                --enable-dns-updates --unattended
          user_name: mydomadmin
          root_password: <password>

    - name: Print vm attributes
      ovirt.ovirt.ovirt_vm_info:
        auth: "{{ ovirt_auth }}"
        pattern: name="{{ vm_fqdn }}"
      register: vm_info
    - debug:
        msg: "{{ vm_info.ovirt_vms[0] }}"

On Sat, Nov 27, 2021 at 12:51 AM Strahil Nikolov <hunter86_bg@yahoo.com> wrote:
>
> yaml is picky...
>
>
> write_files:
>            - path: /tmp/setup.sh
>            permissions: '0755'
>            content: |
>
> permissions & content should be on the same indentation with path:
>
> - path
>  permissions
>  content
>
> What is the error you receive ?
>
>
> Best Regards,
> Strahil Nikolov
>
> On Sat, Nov 27, 2021 at 1:19, Sina Owolabi
> <notify.sina@gmail.com> wrote:
> _______________________________________________
> Users mailing list -- users@ovirt.org
> To unsubscribe send an email to users-leave@ovirt.org
> 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/users@ovirt.org/message/HLTC34PWJICMOLLVCZBE44XOZG7TGWU7/
>


--

cordially yours,


Sina Owolabi


+2348176469061