Skip to content

Commit 11804df

Browse files
Aletibazobalazsbmesk4zuzu
authored
M #-: Improve infra role (#173)
- Automatically pre-install opennebula-node-kvm package on HV nodes - Run early PCI/SR-IOV and OVS/DPDK management on HV nodes - Add support for OVS and OVS + DPDK interfaces for infra VMs - Add qemu-guest-agent to infra VM template - Add SEARCH_DOMAIN and START_SCRIPT_BASE64 as supported context parameters - Update devices to be compatible with machine type q35 - Change templates extension to jinja in infra role Signed-off-by: Alejandro Mosteiro <amosteiro@opennebula.io> Signed-off-by: Balazs Nemeth <bnemeth@opennebula.io> Signed-off-by: Michal Opala <sk4zuzu@gmail.com> Co-authored-by: Balazs Nemeth <bnemeth@opennebula.io> Co-authored-by: Michal Opala <sk4zuzu@gmail.com>
1 parent 319440f commit 11804df

7 files changed

Lines changed: 215 additions & 143 deletions

File tree

playbooks/infra.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,45 @@
44
collections:
55
- opennebula.deploy
66
roles:
7+
# This installs the interpreter only.
8+
# Extra OS/PyPI packages should not required by this playbook.
79
- role: helper/python3
810

911
- role: helper/facts
1012
tags: [always]
1113

12-
- role: helper/cache
14+
- hosts: "{{ (infra_group | d('infra')) ~ ':&' ~ (node_group | d('node')) }}" # intersection
15+
tags: [infra]
16+
collections:
17+
- opennebula.deploy
18+
roles:
19+
- role: helper/kernel # NOTE: it may reboot the machine!
20+
21+
# The helper/pci role does not require OpenNebula cluster to be established
22+
# as it operates strictly on the device layer of the underlying OS.
23+
- role: helper/pci
24+
25+
- role: repository
26+
27+
# The openvswitch role does not require OpenNebula cluster to be established
28+
# as it operates strictly on the device / networking layers of the underlying OS.
29+
- role: openvswitch
30+
tasks:
31+
- name: Install OpenNebula KVM package
32+
ansible.builtin.package:
33+
name: [opennebula-node-kvm]
34+
register: package
35+
until: package is success
36+
retries: 12
37+
delay: 5
1338

39+
- ansible.builtin.include_role:
40+
name: kvm
41+
tasks_from: libvirt
42+
43+
- hosts: "{{ infra_group | d('infra') }}"
44+
tags: [infra]
45+
collections:
46+
- opennebula.deploy
47+
roles:
1448
- role: infra

roles/infra/README.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,40 @@ A role that pre-deploys Front-end VMs directly in Libvirt.
66
Requirements
77
------------
88

9-
Pre-installed Libvirt software.
9+
Pre-installed Libvirt software (in the case of `infra` and `node` groups share hosts, then `opennebula-node-kvm` is pre-installed automatically).
1010

1111
Role Variables
1212
--------------
1313

14-
| Name | Type | Default | Example | Description |
15-
|--------------------------|--------|--------------------|---------------------|-------------------------------------------------------------------|
16-
| `frontend_group` | `str` | `frontend` | | Custom name of the Frontend group in the inventory. |
17-
| `infra_group` | `str` | `infra` | | Custom name of the Infra group in the inventory. |
18-
| | | | | |
19-
| `runtime_dir` | `str` | `/var/one-deploy/` | | Directory used to store QCOW2 and ISO images. |
20-
| `os_image_url` | `str` | (check below) | | HTTP(S) link to Debian/RedHat-like image running `one-contextd`. |
21-
| `os_image_size` | `str` | `20G` | | The size to which one-deploy will **try** to adjust the OS image. |
22-
| `memory_KiB` | `str` | `2097152` | | Memory amount to be set in XML in Libvirt. |
23-
| `vcpu_static` | `str` | `1` | | VCPU amount to be set in XML in Libvirt. |
24-
| `vnc_max_port` | `str` | `65535` | | Upper limit for VNC ports to start counting-down from. |
25-
| `infra_bridge` | `str` | `br0` | | Pre-defined bridge interface to insert VM NICs to. |
26-
| `passthrough_fs` | `list` | `[]` | (check below) | Shared HV filesystems to attach to the Front-end VMs. |
27-
| | | | | |
28-
| `infra_hostname` | `str` | | `n1a1` | Defines on which HV machine the Front-end VM should be deployed. |
29-
| `context.ETH0_DNS` | `str` | | `1.1.1.1` | DNS server. |
30-
| `context.ETH0_GATEWAY` | `str` | | `10.2.50.1` | Gateway. |
31-
| `context.ETH0_IP` | `str` | | `10.2.50.100` | IPv4 address to be set on eth0. |
32-
| `context.ETH0_MAC` | `str` | | `02:01:0a:02:32:64` | MAC address to be set on eth0 (**MUST** match MAC set in XML.) |
33-
| `context.ETH0_MASK` | `str` | | `255.255.255.0` | Network mask. |
34-
| `context.ETH0_NETWORK` | `str` | | `10.2.50.0` | Network address. |
35-
| `context.GROW_FS` | `str` | `/` | | Filesystems to grow. |
36-
| `context.PASSWORD` | `str` | `opennebula` | | Root's password. |
37-
| `context.SET_HOSTNAME` | `str` | name of the FE VM | | Hostname. |
38-
| `context.SSH_PUBLIC_KEY` | `str` | | (check below) | Root's extra authorized keys. |
14+
| Name | Type | Default | Example | Description |
15+
|--------------------------------------|--------|--------------------|---------------------|-------------------------------------------------------------------|
16+
| `frontend_group` | `str` | `frontend` | | Custom name of the Frontend group in the inventory. |
17+
| `infra_group` | `str` | `infra` | | Custom name of the Infra group in the inventory. |
18+
| | | | | |
19+
| `runtime_dir` | `str` | `/var/one-deploy/` | | Directory used to store QCOW2 and ISO images. |
20+
| `os_image_url` | `str` | | | HTTP(S) link to Debian/RedHat-like image running `one-contextd`. |
21+
| `os_image_size` | `str` | `20G` | | The size to which one-deploy will **try** to adjust the OS image. |
22+
| `memory_KiB` | `str` | `2097152` | | Memory amount to be set in XML in Libvirt. |
23+
| `vcpu_static` | `str` | `1` | | VCPU amount to be set in XML in Libvirt. |
24+
| `vnc_max_port` | `str` | `65535` | | Upper limit for VNC ports to start counting-down from. |
25+
| `passthrough_fs` | `list` | `[]` | (check below) | Shared HV filesystems to attach to the Front-end VMs. |
26+
| | | | | |
27+
| `infra_bridge` | `str` | `br0` | | Pre-defined bridge interface to insert VM NICs to. |
28+
| `infra_bridge_type` | `str` | `bridge` | | Supported values: bridge, openvswitch, openvswitch_dpdk |
29+
| `infra_dpdk_socket_path` | `str` | | | Path for existing socket when using OVS with DPDK. |
30+
| `infra_vlan_id` | `str` | | | Optionally set the VLAN ID for the bridge. |
31+
| `infra_hostname` | `str` | | `n1a1` | Defines on which HV machine the Front-end VM should be deployed. |
32+
| `context.ETH0_DNS` | `str` | | `1.1.1.1` | DNS server. |
33+
| `context.ETH0_SEARCH_DOMAIN` | `str` | | `1.1.1.1` | DNS search domain. |
34+
| `context.ETH0_GATEWAY` | `str` | | `10.2.50.1` | Gateway. |
35+
| `context.ETH0_IP` | `str` | | `10.2.50.100` | IPv4 address to be set on eth0. |
36+
| `context.ETH0_MAC` | `str` | | `02:01:0a:02:32:64` | MAC address to be set on eth0 (**MUST** match MAC set in XML.) |
37+
| `context.ETH0_MASK` | `str` | | `255.255.255.0` | Network mask. |
38+
| `context.ETH0_NETWORK` | `str` | | `10.2.50.0` | Network address. |
39+
| `context.GROW_FS` | `str` | `/` | | Filesystems to grow. |
40+
| `context.PASSWORD` | `str` | `opennebula` | | Root's password. |
41+
| `context.SET_HOSTNAME` | `str` | name of the FE VM | | Hostname. |
42+
| `context.SSH_PUBLIC_KEY` | `str` | | (check below) | Root's extra authorized keys. |
3943

4044
**NOTE**: The `infra_hostname` and `context` dictionary should be set for members of the `frontend` group (please check the `inventory/infra.yml` example).
4145

roles/infra/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ memory_KiB: 2097152 # 2 GiB
66
vcpu_static: 1
77
vnc_max_port: 65535
88
infra_bridge: br0
9+
infra_bridge_type: bridge
910
passthrough_fs: []

roles/infra/tasks/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
- name: Create context.sh files
3535
ansible.builtin.template:
3636
dest: "{{ tempfile.results[item].path }}/context.sh"
37-
src: context.sh.j2
37+
src: context.sh.jinja
3838
mode: ug=rw,o=
3939
vars:
4040
frontend: "{{ tempfile.results[item].frontend }}"
@@ -100,7 +100,7 @@
100100
- name: Define Front-end VMs
101101
community.libvirt.virt:
102102
command: define
103-
xml: "{{ lookup('template', 'frontend.xml.j2') }}"
103+
xml: "{{ lookup('template', 'frontend.xml.jinja') }}"
104104
autostart: true
105105
vars:
106106
context: "{{ hostvars[frontend].context }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Context variables generated by one-deploy
22
DISK_ID='1'
33
ETH0_DNS='{{ context.ETH0_DNS }}'
4+
ETH0_SEARCH_DOMAIN='{{ context.ETH0_SEARCH_DOMAIN }}'
45
ETH0_GATEWAY='{{ context.ETH0_GATEWAY }}'
56
ETH0_IP='{{ context.ETH0_IP }}'
67
ETH0_MAC='{{ context.ETH0_MAC | d("02:01:%02x:%02x:%02x:%02x" | format(*(context.ETH0_IP.split(".") | map("int")))) }}'
@@ -12,3 +13,6 @@ PASSWORD='{{ context.PASSWORD | d("opennebula") }}'
1213
SET_HOSTNAME='{{ context.SET_HOSTNAME | d(frontend) }}'
1314
SSH_PUBLIC_KEY='{{ context.SSH_PUBLIC_KEY | d("") }}'
1415
TARGET='hda'
16+
{% if context.START_SCRIPT_BASE64 is defined %}
17+
START_SCRIPT_BASE64='{{ context.START_SCRIPT_BASE64 | b64encode }}'
18+
{% endif %}

roles/infra/templates/frontend.xml.j2

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)