oVirt automation through Ansible and cloud-init in oVirt 4.1.5 + Ansible 2.3.1

oVirt Version: 4.1.5 Ansible: 2.3.1 Hello Friends of oVirt I want to automate the creation, provisioning and deployment of virtual machines in oVirt, using Ansible. I want to use a non-cloud image for the template. It has cloud-init installed. And it looks for the IP http: //169.254.169 and the following error message: "Calling 'http: //169.254.169 ....." It looks like oVirt uses a config drive with a user-data.txt file This is my Ansible Playbook: --- # Primer Play - hosts: oVirtEnginePruebas remote_user: root tasks: - name : Definiendo la conexion con el Engine de oVirt ovirt_auth: url: https://engine1.example.com/ovirt-engine/api username: admin@internal password: mysupersecretpassword ca_file: /etc/pki/ovirt-engine/ca.pem - name : Creando la maquina virtual requerida ovirt_vms: auth: "{{ ovirt_auth }}" state: present name: CentOS7CloudInit template: CloudInitTemplate cluster: Default - name : Se establecen las propiedades de la maquina virtual y los parametros de cloud-init ovirt_vms: auth: "{{ ovirt_auth }}" name: CentOS7CloudInit template: CloudInitTemplate cluster: Default memory: 5GiB cpu_cores: 8 high_availability: true cloud_init: host_name: cloudinit.example.com nic_name: eth0 nic_boot_protocol: static nic_ip_address: 192.168.0.238 nic_netmask: 255.255.255.0 nic_gateway: 192.168.0.1 dns_servers: 8.8.8.8 dns_search: example.com nic_on_boot: true user_name: root root_password: mysupersecretpassword - name : Desconectando con el Engine de oVirt revocando el token SSO ovirt_auth: state: absent ovirt_auth: "{{ ovirt_auth }}" ~ I just want to use Ansible for this, I do not want to use the oVirt webinterface to run run once every time I want to provision a machine. How can I do that ? Thanks in advance

On Sat, Sep 9, 2017 at 2:02 AM, Julián Tete <danteconrad14@gmail.com> wrote:
oVirt Version: 4.1.5
Ansible: 2.3.1
Hello Friends of oVirt
I want to automate the creation, provisioning and deployment of virtual machines in oVirt, using Ansible.
I want to use a non-cloud image for the template. It has cloud-init installed. And it looks for the IP http: //169.254.169 and the following error message: "Calling 'http: //169.254.169 ....."
It looks like oVirt uses a config drive with a user-data.txt file
This is my Ansible Playbook:
--- # Primer Play - hosts: oVirtEnginePruebas remote_user: root tasks: - name : Definiendo la conexion con el Engine de oVirt ovirt_auth: url: https://engine1.example.com/ovirt-engine/api username: admin@internal password: mysupersecretpassword ca_file: /etc/pki/ovirt-engine/ca.pem
- name : Creando la maquina virtual requerida ovirt_vms: auth: "{{ ovirt_auth }}" state: present name: CentOS7CloudInit template: CloudInitTemplate cluster: Default
Why you need this? I think you can remove and use just the task below.
- name : Se establecen las propiedades de la maquina virtual y los parametros de cloud-init ovirt_vms: auth: "{{ ovirt_auth }}" name: CentOS7CloudInit template: CloudInitTemplate cluster: Default memory: 5GiB cpu_cores: 8 high_availability: true cloud_init: host_name: cloudinit.example.com nic_name: eth0 nic_boot_protocol: static nic_ip_address: 192.168.0.238 nic_netmask: 255.255.255.0 nic_gateway: 192.168.0.1 dns_servers: 8.8.8.8 dns_search: example.com nic_on_boot: true user_name: root root_password: mysupersecretpassword
This looks OK, and should work, what is the issue you have?
- name : Desconectando con el Engine de oVirt revocando el token SSO ovirt_auth: state: absent ovirt_auth: "{{ ovirt_auth }}" ~
I just want to use Ansible for this, I do not want to use the oVirt webinterface to run run once every time I want to provision a machine.
How can I do that ?
Thanks in advance
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

You are absolutely right Ondra. Thank You I have three questions for you: 1) How does this work ? Ansible creates the configuration disk? 2) How can I do to disable cloud-init after execution, maybe a script that runs systemd disable cloud-init.service and systemd mask cloud-init.service. There is little documentation about it 3) If you would like to turn off or on a huge set of virtual machines how you can group them to do so. Without having to do a Task for each one 2017-09-11 4:25 GMT-05:00 Ondra Machacek <omachace@redhat.com>:
On Sat, Sep 9, 2017 at 2:02 AM, Julián Tete <danteconrad14@gmail.com> wrote:
oVirt Version: 4.1.5
Ansible: 2.3.1
Hello Friends of oVirt
I want to automate the creation, provisioning and deployment of virtual machines in oVirt, using Ansible.
I want to use a non-cloud image for the template. It has cloud-init installed. And it looks for the IP http: //169.254.169 and the following error message: "Calling 'http: //169.254.169 ....."
It looks like oVirt uses a config drive with a user-data.txt file
This is my Ansible Playbook:
--- # Primer Play - hosts: oVirtEnginePruebas remote_user: root tasks: - name : Definiendo la conexion con el Engine de oVirt ovirt_auth: url: https://engine1.example.com/ovirt-engine/api username: admin@internal password: mysupersecretpassword ca_file: /etc/pki/ovirt-engine/ca.pem
- name : Creando la maquina virtual requerida ovirt_vms: auth: "{{ ovirt_auth }}" state: present name: CentOS7CloudInit template: CloudInitTemplate cluster: Default
Why you need this? I think you can remove and use just the task below.
- name : Se establecen las propiedades de la maquina virtual y los parametros de cloud-init ovirt_vms: auth: "{{ ovirt_auth }}" name: CentOS7CloudInit template: CloudInitTemplate cluster: Default memory: 5GiB cpu_cores: 8 high_availability: true cloud_init: host_name: cloudinit.example.com nic_name: eth0 nic_boot_protocol: static nic_ip_address: 192.168.0.238 nic_netmask: 255.255.255.0 nic_gateway: 192.168.0.1 dns_servers: 8.8.8.8 dns_search: example.com nic_on_boot: true user_name: root root_password: mysupersecretpassword
This looks OK, and should work, what is the issue you have?
- name : Desconectando con el Engine de oVirt revocando el token SSO ovirt_auth: state: absent ovirt_auth: "{{ ovirt_auth }}" ~
I just want to use Ansible for this, I do not want to use the oVirt webinterface to run run once every time I want to provision a machine.
How can I do that ?
Thanks in advance
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On Sat, Sep 16, 2017 at 3:47 AM, Julián Tete <danteconrad14@gmail.com> wrote:
You are absolutely right Ondra. Thank You
Also to me seems ok, is similar to the configuration we're using to deploy.
I have three questions for you:
1) How does this work ? Ansible creates the configuration disk?
You mean cloud-init configuration-disk? no, the work is directly done by oVirt. oVirt knows what you want to put into the configuration drive and creates a new cdrom device with the configuration drive to be attached directly to the vm during "Run Once". Once restarted with standard "Run" the device disappears.
2) How can I do to disable cloud-init after execution, maybe a script that runs systemd disable cloud-init.service and systemd mask cloud-init.service. There is little documentation about it
I simply run a task after first successful boot with cloud-init that runs yum erase -y cloud-init
3) If you would like to turn off or on a huge set of virtual machines how you can group them to do so. Without having to do a Task for each one
What do you mean grouping? via engine interface you can apply a tag to them and then lookup by tag, select all and shutdown. -- "E' assurdo impiegare gli uomini di intelligenza eccellente per fare calcoli che potrebbero essere affidati a chiunque se si usassero delle macchine" Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716) "Internet è la più grande biblioteca del mondo. Ma il problema è che i libri sono tutti sparsi sul pavimento" John Allen Paulos, Matematico (1945-vivente) Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenzetto.luca@gmail.com>

On Sep 16, 2017 11:50 AM, "Luca 'remix_tj' Lorenzetto" < lorenzetto.luca@gmail.com> wrote: On Sat, Sep 16, 2017 at 3:47 AM, Julián Tete <danteconrad14@gmail.com> wrote:
You are absolutely right Ondra. Thank You
Also to me seems ok, is similar to the configuration we're using to deploy.
I have three questions for you:
1) How does this work ? Ansible creates the configuration disk?
You mean cloud-init configuration-disk? no, the work is directly done by oVirt. oVirt knows what you want to put into the configuration drive and creates a new cdrom device with the configuration drive to be attached directly to the vm during "Run Once". Once restarted with standard "Run" the device disappears.
2) How can I do to disable cloud-init after execution, maybe a script that runs systemd disable cloud-init.service and systemd mask
cloud-init.service.
There is little documentation about it
I simply run a task after first successful boot with cloud-init that runs yum erase -y cloud-init
3) If you would like to turn off or on a huge set of virtual machines how you can group them to do so. Without having to do a Task for each one
What do you mean grouping? via engine interface you can apply a tag to them and then lookup by tag, select all and shutdown. Or use Ansible 'with' or give all the VMs as the targets for the task. Y. -- "E' assurdo impiegare gli uomini di intelligenza eccellente per fare calcoli che potrebbero essere affidati a chiunque se si usassero delle macchine" Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716) "Internet è la più grande biblioteca del mondo. Ma il problema è che i libri sono tutti sparsi sul pavimento" John Allen Paulos, Matematico (1945-vivente) Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , < lorenzetto.luca@gmail.com> _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (4)
-
Julián Tete
-
Luca 'remix_tj' Lorenzetto
-
Ondra Machacek
-
Yaniv Kaul