docs: update for J-Release
[pti/rtp.git] / okd / roles / ocloud_infra_vm / tasks / main.yml
1 ---
2 - name: Define virtual network - {{ ocloud_net_name }}
3   community.libvirt.virt_net:
4     command: define
5     name: "{{ ocloud_net_name }}"
6     xml: '{{ lookup("template", "virt_net.xml.j2") }}'
7   run_once: true
8   become: true
9
10 - name: Activate virtual network - {{ ocloud_net_name }}
11   community.libvirt.virt_net:
12     name: "{{ ocloud_net_name }}"
13     state: active
14   run_once: true
15   become: true
16
17 - name: Configure virtual network to auto-start - {{ ocloud_net_name }}
18   community.libvirt.virt_net:
19     name: "{{ ocloud_net_name }}"
20     autostart: true
21   run_once: true
22   become: true
23
24 - name: Locate qemu-kvm emulator
25   stat:
26     path: "{{ item }}"
27   register: ocloud_infra_vm_emulator_stat
28   loop:
29     - /usr/bin/qemu-kvm
30     - /usr/libexec/qemu-kvm
31
32 - set_fact:
33     ocloud_infra_vm_emulator_path: "{{ item.stat.path }}"
34   when: item.stat.exists
35   loop: "{{ ocloud_infra_vm_emulator_stat.results }}"
36
37 - name: Create virtual machine - {{ inventory_hostname }}
38   community.libvirt.virt:
39     command: define
40     xml: '{{ lookup("template", "virt.xml.j2") }}'
41   register: ocloud_infra_vm_definition
42   become: true
43
44 - name: Create VM disk
45   ansible.builtin.command:
46     cmd: "qemu-img create -f qcow2 {{ ocloud_infra_vm_disk_path }} {{ ocloud_infra_vm_disk_gb }}G"
47   when: ocloud_infra_vm_definition.changed
48   become: true
49
50 - name: Copy platform boot image
51   ansible.builtin.copy:
52     src: "{{ ocloud_platform_image }}"
53     dest: "{{ ocloud_infra_vm_image }}"
54     remote_src: true
55   when: ocloud_infra_vm_definition.changed
56   become: true
57
58 - name: Activate virtual machine - {{ inventory_hostname }}
59   community.libvirt.virt:
60     name: "{{ inventory_hostname }}"
61     state: running
62   notify: monitor_platform_deployment
63   become: true