Thanks guys, not sure why the ansible isnt showing up, Posting again:
- 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: present clone: true cluster: lrg0-ovirt-cluster storage_domain: lrg0-ovirt-mydom-internal-Local memory: 16GiB cpu_cores: 8 cpu_sockets: 2 template: template-test00-centos8 type: server operating_system: other_linux sso: true disk_format: raw # disks: # - name: "{{ vm_fqdn }}-disk0" # bootable: true # nics: # - name: nic1 # boot_protocol: dhcp # interface: virtio # profile_name: "{{ net_profile_name }}" graphical_console: protocol: - spice - vnc cloud_init: custom_script: | host_name: "{{ vm_fqdn }}" user_name: myadmin user_password: <password> write_files: - path: /tmp/setup.sh permissions: '0755' content: | #!/bin/bash echo "$(hostnamectl)" >> /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 runcmd: - [ /tmp/setup.sh, "{{ vm_fqdn }}" ] On Fri, Nov 26, 2021 at 5:11 PM Staniforth, Paul < p.stanifo...@leedsbeckett.ac.uk> wrote: > Hi Sina, > I get easily confused with cloud-init but shouldn't you be > setting the hostname, username, etc before the custom script? > > Also, you could rename the disk as a separate play in your playbook. > > e.g. > > # Change Disk Name- ovirt.ovirt.ovirt_disk: > id: 00000000-0000-0000-0000-000000000000 > storage_domain: data > name: "new_disk_name" > vm_name: rhel7 > > > Regards, > Paul S. > > ------------------------------ > *From:* Sina Owolabi <notify.s...@gmail.com> > *Sent:* 26 November 2021 15:00 > *To:* Staniforth, Paul <p.stanifo...@leedsbeckett.ac.uk> > *Cc:* users@ovirt.org <users@ovirt.org> > *Subject:* Re: [ovirt-users] Re: Creating VMs from templates with their > own disks > > > *Caution External Mail:* Do not click any links or open any attachments > unless you trust the sender and know that the content is safe. > Thanks Paul. > > I seem to be getting this by hand, but trying with ansible, I think my > skills are a bit lacking. > I can create with ansible, and it seems to work well, except for the fact > that the new vm is > created with the hostname of the vm from which the template was made. > The disk is also named by the template. > My ansiblle yaml is below and I'm pretty sure its wrong (especially where > it needs to use cloud-init to inject the correct hostname, and the other > prepping I would like to add). > Please can you help correct me? > > --- > - 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: present > clone: true > cluster: lrg0-ovirt-cluster > storage_domain: lrg0-ovirt-mydom-internal-Local > memory: 16GiB > cpu_cores: 8 > cpu_sockets: 2 > template: template-test00-centos8 > type: server > operating_system: other_linux > sso: true > disk_format: raw > # disks: > # - name: "{{ vm_fqdn }}-disk0" > # bootable: true > # nics: > # - name: nic1 > # boot_protocol: dhcp > # interface: virtio > # profile_name: "{{ net_profile_name }}" > graphical_console: > protocol: > - spice > - vnc > cloud_init: > custom_script: | > host_name: "{{ vm_fqdn }}" > user_name: myadmin > user_password: <password> > write_files: > - path: /tmp/setup.sh > permissions: '0755' > content: | > #!/bin/bash > echo "$(hostnamectl)" >> /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 > runcmd: > - [ /tmp/setup.sh, "{{ vm_fqdn }}" ] > > On Wed, Nov 24, 2021 at 9:26 PM Staniforth, Paul < > p.stanifo...@leedsbeckett.ac.uk> wrote: > > Hello Sina, > > to use the template. > > Create new VM and select the template. > > Click the advanced options. > > In the boot section you can set the HD to be the first boot devices and > unselect any CD. > In the Resource Allocation section, you can set the storage allocation to > clone instead of thin ( this will create a copy of the template disk), you > can also set the disk alias name. > > you can also edit the template to make sure the HD is the first boot > device. > > I don't know what's in your ansible yaml definition. > > Cloning is for copying VMs or snapshots not templates. > > Regards, > > Paul S. > ------------------------------ > *From:* Sina Owolabi <notify.s...@gmail.com> > *Sent:* 24 November 2021 09:28 > *To:* Staniforth, Paul <p.stanifo...@leedsbeckett.ac.uk> > *Cc:* users@ovirt.org <users@ovirt.org> > *Subject:* Re: [ovirt-users] Re: Creating VMs from templates with their > own disks > > > *Caution External Mail:* Do not click any links or open any attachments > unless you trust the sender and know that the content is safe. > Hello > > Sorry for the late reply, work has been crazy. > > This doesnt seem to work as advertised, or I am still not getting it. > Either way I would really appreciate some help and guidance. > > Steps I have attempted: > 1. Create and configure VM as I want it to be (disk, partitioning, etc). > 2. Shutdown the vm, create a template from it. > > Cloning manually: > Cloning fails with this message: > Error while executing action: > clone00.domain.tld: > > - Cannot add VM. One or more provided storage domains are either not > in active status or of an illegal type for the requested operation. > > I cant modify the storage allocation, and the disk its attempting to use > is the disk of the source VM. > > Manual template install: > Choosing to install manually with a template requires me to add a new > disk, and to boot off the CD (defined in the template) and manually set > things up. This I do not wish to do, because I would rather automate. > > Cloning with ansible, defining the cloud-init script and using the > template: > VM is successfully created, but logging in with remote-viewer drops me > into the installation process (setting up from the attached ISO). Which is > also not desired. > > Please help me with what I am doing wrong. > Again the goal is to have the vm setup with its own credentials. > > > On Thu, Nov 18, 2021 at 9:24 AM Staniforth, Paul < > p.stanifo...@leedsbeckett.ac.uk> wrote: > > Hello, > The VMs can get created from a template otherwise the blank > template is used if a particular template is used it can be thin dependent > VM the VMs disks is linked to the Templates disk and it just carries the > changes made in the VMs disk (this is quicker and uses less space if you a > lot of disks). The other option is to create a cloned VM and this will copy > the Templates disk to the VM so it's no longer dependent. > > In the ansible documentation look for the clone option. > > https://docs.ansible.com/ansible/latest/collections/ovirt/ovirt/ovirt_vm_module.html > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.ansible.com%2Fansible%2Flatest%2Fcollections%2Fovirt%2Fovirt%2Fovirt_vm_module.html&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342221277%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=hmFbTYZ%2BR%2FqpZRd0kO9Wo83r41A5G2%2FSmhvdbqI3wMA%3D&reserved=0> > > > https://www.ovirt.org/documentation/virtual_machine_management_guide/index.html > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fdocumentation%2Fvirtual_machine_management_guide%2Findex.html&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342231283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Ky0gGxa1xFv8kr8yDOY%2FqK%2FEPF%2FEDk3zn15rEfSIfMQ%3D&reserved=0> > Virtual Machine Management Guide > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fdocumentation%2Fvirtual_machine_management_guide%2Findex.html&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342231283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Ky0gGxa1xFv8kr8yDOY%2FqK%2FEPF%2FEDk3zn15rEfSIfMQ%3D&reserved=0> > oVirt is a free open-source virtualization solution for your entire > enterprise > www.ovirt.org > <https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ovirt.org%2F&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342241264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=63JBeaJQbCCIlI4%2Bf27mooDcxXHlcWwgVMsRaE1Zo2I%3D&reserved=0> > For the cloud-init does the cloud-init package need to be installed on the > template image? > > > Regards, > > Paul S. > ------------------------------ > *From:* notify.s...@gmail.com <notify.s...@gmail.com> > *Sent:* 18 November 2021 07:34 > *To:* users@ovirt.org <users@ovirt.org> > *Subject:* [ovirt-users] Re: Creating VMs from templates with their own > disks > > Caution External Mail: Do not click any links or open any attachments > unless you trust the sender and know that the content is safe. > > Im sorry, I am trying to wrap my head around this but it is difficult. > > I just want to be able to stand up new vms, with their own storage, > similar to how I can with plain vanilla KVM, with a template or without, > maybe even with a kickstart, and hopefully with ansible. > > Right now anytime I try to create a VM, using the template, (with > ansible), it gets the template disk attached, and from the console I see > the new vm is named as the vm I created the template with. Cloud init > script that is meant to rename the vm, and join it to IPA, is ignored. > > If I create storage for the vm, before creating it, both the template > storage and the new storage are attached to the vm, which is also > confusing. Cloud init is also ignored. > > I didn't think something this straightforward would end up needing a shift > in thinking about how vms are created, especially with a product that's > more than likely using kvm under the hood. > > I would appreciate some straightforward guiding steps, if I can get them. > Really. It's been a frustrating week. > > > > On 2021-11-17 13:50, Sina Owolabi wrote: > > > > > > You can create a template with no disk, then VM's created from that > > template will also have no disk. Then add a new disk to the VM after you > > create it. This is how the default blank template works. You can also > > create a template with an empty disk, then every VM created will also > > get an empty disk by default. You can always rename disks as well. > _______________________________________________ > Users mailing list -- users@ovirt.org > To unsubscribe send an email to users-le...@ovirt.org > Privacy Statement: > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fprivacy-policy.html&data=04%7C01%7Cp.staniforth%40leedsbeckett.ac.uk%7Ce92dfae2d8d64a8a5d2308d9aa660b23%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637728177667805891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=wIZvVNcinh35Ufj0jodhjIVWj2LtY%2FYgP77rUh0%2BCLs%3D&reserved=0 > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fprivacy-policy.html&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342251257%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=3CFpFqO5BBQXtQQEvg%2B7w948fV9076FVdM8mG2kl3pY%3D&reserved=0> > oVirt Code of Conduct: > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fcommunity%2Fabout%2Fcommunity-guidelines%2F&data=04%7C01%7Cp.staniforth%40leedsbeckett.ac.uk%7Ce92dfae2d8d64a8a5d2308d9aa660b23%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637728177667805891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=c%2FCRWL1QjhgQV01hQgph83eW9RtyE83cWPWD%2BN6kmIQ%3D&reserved=0 > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ovirt.org%2Fcommunity%2Fabout%2Fcommunity-guidelines%2F&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342251257%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=cHvhgL4qhcqJnEoni245QQrBjeFBLTdnqJWu%2B%2BwDJgo%3D&reserved=0> > List Archives: > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.ovirt.org%2Farchives%2Flist%2Fusers%40ovirt.org%2Fmessage%2FURJROHMP6M3LJWAM6A4QMLFXUIYLGPOZ%2F&data=04%7C01%7Cp.staniforth%40leedsbeckett.ac.uk%7Ce92dfae2d8d64a8a5d2308d9aa660b23%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637728177667805891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=cU62Whas54HNQp8N4r24gCaMXtxaakPrjOjjdbY95mE%3D&reserved=0 > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.ovirt.org%2Farchives%2Flist%2Fusers%40ovirt.org%2Fmessage%2FURJROHMP6M3LJWAM6A4QMLFXUIYLGPOZ%2F&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342261252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=x1Yars%2FlppeqwB9IiW9akpx4gYhStCJX98O8PgZppTU%3D&reserved=0> > To view the terms under which this email is distributed, please go to:- > https://leedsbeckett.ac.uk/disclaimer/email > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fleedsbeckett.ac.uk%2Fdisclaimer%2Femail&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342271245%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=borquuqwhg5vF%2ByxR%2FvlcX41GJZY8WMUB8NTNcE99%2Bk%3D&reserved=0> > > > > -- > > cordially yours, > > Sina Owolabi > > +2348176469061 > To view the terms under which this email is distributed, please go to:- > https://leedsbeckett.ac.uk/disclaimer/email > <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fleedsbeckett.ac.uk%2Fdisclaimer%2Femail&data=04%7C01%7CP.Staniforth%40leedsbeckett.ac.uk%7C5abd83403bc94d28618808d9b0ed7d59%7Cd79a81124fbe417aa112cd0fb490d85c%7C0%7C0%7C637735356342271245%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=borquuqwhg5vF%2ByxR%2FvlcX41GJZY8WMUB8NTNcE99%2Bk%3D&reserved=0> > > > > -- > > cordially yours, > > Sina Owolabi > > +2348176469061 > To view the terms under which this email is distributed, please go to:- > https://leedsbeckett.ac.uk/disclaimer/email > > -- cordially yours, Sina Owolabi +2348176469061
_______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-le...@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/M5XUNDXVWDBZM74YDPZ2GXILYT2YVTGV/