OKD O-Cloud implementation
[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: Create virtual machine - {{ inventory_hostname }}
25   community.libvirt.virt:
26     command: define
27     xml: '{{ lookup("template", "virt.xml.j2") }}'
28   register: ocloud_infra_vm_definition
29   become: true
30
31 - name: Create VM disk
32   ansible.builtin.command:
33     cmd: "qemu-img create -f qcow2 {{ ocloud_infra_vm_disk_path }} {{ ocloud_infra_vm_disk_gb }}G"
34   when: ocloud_infra_vm_definition.changed
35   become: true
36
37 - name: Copy platform boot image
38   ansible.builtin.copy:
39     src: "{{ ocloud_platform_image }}"
40     dest: "{{ ocloud_infra_vm_image }}"
41     remote_src: true
42   when: ocloud_infra_vm_definition.changed
43   become: true
44
45 - name: Activate virtual machine - {{ inventory_hostname }}
46   community.libvirt.virt:
47     name: "{{ inventory_hostname }}"
48     state: running
49   notify: monitor_platform_deployment
50   become: true