Skip to content

Commit 82cef0e

Browse files
committed
Add playbooks to set up the nat64 net and VM
Playbook to configure the nat64 appliance and networks on libvirt. Molecule test builds the nat64 appliance image, deploys it. Tests also create an additional IPv6 network, a test instance and verfies that the test instance can ping example.com.
1 parent 7570d14 commit 82cef0e

File tree

15 files changed

+722
-15
lines changed

15 files changed

+722
-15
lines changed

docs/dictionary/en-custom.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ svg
458458
svgrepo
459459
svm
460460
systemd
461+
tayga
461462
tcib
462463
tdciagigtlesa
463464
tempestconf
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{ cifmw_config_drive_networkconfig | to_nice_yaml(indent=2, default_style="\"") }}
1+
{{ cifmw_config_drive_networkconfig | to_nice_yaml(indent=2) }}

roles/nat64_appliance/README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
# nat64_appliance
22

3-
`diskimage-builder` definition and element to build a NAT64 + DNS64 appliance VM image.
3+
`main.yml`: Tasks to build a NAT64 + DNS64 appliance VM image, uses `diskimage-builder`.
4+
`deploy.yml`: Tasks to deploy networks and appliance VM on a libvirt hypervisor.
5+
`cleanup.yml`: Tasks to destroy and undefine the VM and networks on a libvirt hypervisor, and delete the built image.
46

57
## Parameters
68

79
* `cifmw_nat64_appliance_basedir`: (String) Base directory. Defaults to `{{ cifmw_basedir }}` which defaults to `~/ci-framework-data`.
810
* `cifmw_nat64_appliance_workdir`: (String) Working directory. Defaults to `{{ cifmw_nat64_appliance_basedir }}/nat64_appliance`.
911
* `cifmw_nat64_appliance_venv_dir`: (String) Python virtual environment directory. Defaults to `{{ cifmw_nat64_appliance_workdir }}/venv`.
12+
* `cifmw_nat64_libvirt_uri`: (String) The libvirt URI for the hypervisor to deploy on. Defaults to `qemu:///system`.
13+
* `cifmw_nat64_network_ipv4_name`: (String) Name of the nat64 IPv4 libvirt network. Defaults to: `nat64-net-v4`.
14+
* `cifmw_nat64_network_ipv4_bridge_name`: (String) Bridge name for the nat64 IPv4 libvirt network. Defaults to: `br-64v4`.
15+
* `cifmw_nat64_network_ipv4_address`: (String) IP address for the nat64 IPv4 libvirt network. Defaults to: `172.31.255.1`.
16+
* `cifmw_nat64_network_ipv4_prefix`: (Integer) IP prefix length for the nat64 IPv4 libvirt network. Defaults to: `24`.
17+
* `cifmw_nat64_network_ipv6_name`: (String) Name of the nat64 IPv6 libvirt network. Defaults to: `nat64-net-v6`.
18+
* `cifmw_nat64_network_ipv6_bridge_name`: (String) The bridge name for the nat64 IPv6 libvirt network. Defaults to: `br-64v6`.
19+
* `cifmw_nat64_network_ipv6_address`: (String) IP address for the nat64 IPv6 libvirt network. Defaults to: `fd00:abcd:abcd:fc00::1`.
20+
* `cifmw_nat64_network_ipv6_prefix`: (Integer) IP prefix length for the nat64 IPv6 libvirt network. Defaults to: `64`.
21+
* `cifmw_nat64_appliance_name`: (String) Name and hostname for the nat64 appliance VM. Defaults to: `nat64-appliance`.
22+
* `cifmw_nat64_appliance_ipv4_address`: (String) IPv4 address for the nat64 appliance VM. Defaults to: `172.31.255.2`.
23+
* `cifmw_nat64_appliance_ipv6_address`: (String) IPv6 address for the nat64 appliance VM. Defaults to: `fd00:abcd:abcd:fc00::2`.
24+
* `cifmw_nat64_appliance_memory`: (Integer) Memory in GiB for the nat64 appliance VM. Defaults to: `2`.
25+
* `cifmw_nat64_appliance_cpus`: (Integer) Virtual CPUs for the nat64 appliance VM. Defaults to: `2`.
26+
* `cifmw_nat64_appliance_ssh_pub_key`: (String) Path to ssh public key for the nat64 appliance VM. Defaults to: `{{ ansible_user_dir }}/.ssh/id_rsa.pub`
27+
* `cifmw_nat64_ipv6_prefix`: (String) IPv6 prefix for nat64. Defaults to: `fd00:abcd:abcd:fc00::/64`.
28+
* `cifmw_nat64_ipv6_tayga_address`: (String) Tayga IPv6 address. Defaults to: `fd00:abcd:abcd:fc00::3`.
1029

1130
## Building the image
1231

@@ -18,12 +37,34 @@ Include the `nat64_appliance` role in a playbook. For example:
1837
roles:
1938
- nat64_appliance
2039
```
21-
The built image will be in: `{{ cifmw_basedir }}/artifacts/roles/nat64-appliance/nat64-appliance.qcow2`
40+
41+
The built image will be in: `{{ cifmw_nat64_appliance_workdir }}/nat64-appliance.qcow2`
2242

2343
## Using the nat64-appliance
2444

25-
- [With Openstack cloud](#with-openstack-cloud){#toc-with-openstack-cloud}
2645
- [With Libvirt](#with-libvirt){#toc-with-libvirt}
46+
- [With Openstack cloud](#with-openstack-cloud){#toc-with-openstack-cloud}
47+
48+
### With Libvirt
49+
50+
```
51+
- name: "Build nat64 appliance image"
52+
ansible.builtin.include_role:
53+
name: nat64_appliance
54+
- name: "Deploy the nat64 appliance and networks"
55+
ansible.builtin.include_role:
56+
name: nat64_appliance
57+
tasks_from: deploy.yml
58+
```
59+
60+
To cleanup the libvirt nat64 deployment:
61+
```
62+
- name: "Build nat64 appliance image"
63+
ansible.builtin.include_role:
64+
name: nat64_appliance
65+
tasks_from: cleanup.yml
66+
```
67+
2768

2869
### With Openstack cloud
2970

@@ -220,7 +261,3 @@ $ ssh -J [email protected] fedora@fd00:abcd:aaaa:fc00::2b8
220261
PING sunet.se(fd00:abcd:abcd:fcff::259c:c033 (fd00:abcd:abcd:fcff::259c:c033)) 56 data bytes
221262
64 bytes from fd00:abcd:abcd:fcff::259c:c033 (fd00:abcd:abcd:fcff::259c:c033): icmp_seq=1 ttl=53 time=4.91 ms
222263
```
223-
224-
### With Libvirt
225-
226-
TODO

roles/nat64_appliance/defaults/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ cifmw_nat64_appliance_basedir: >-
2020
}}
2121
cifmw_nat64_appliance_workdir: "{{ cifmw_nat64_appliance_basedir }}/nat64_appliance"
2222
cifmw_nat64_appliance_venv_dir: "{{ cifmw_nat64_appliance_workdir }}/venv"
23+
24+
cifmw_nat64_libvirt_uri: "qemu:///system"
25+
cifmw_nat64_network_ipv4_name: nat64-net-v4
26+
cifmw_nat64_network_ipv4_bridge_name: br-64v4
27+
cifmw_nat64_network_ipv4_address: 172.31.255.1
28+
cifmw_nat64_network_ipv4_prefix: 24
29+
30+
cifmw_nat64_network_ipv6_name: nat64-net-v6
31+
cifmw_nat64_network_ipv6_bridge_name: br-64v6
32+
cifmw_nat64_network_ipv6_address: fd00:abcd:abcd:fc00::1
33+
cifmw_nat64_network_ipv6_prefix: 64
34+
cifmw_nat64_appliance_name: nat64-appliance
35+
cifmw_nat64_appliance_ipv4_address: 172.31.255.2
36+
cifmw_nat64_appliance_ipv6_address: fd00:abcd:abcd:fc00::2
37+
38+
cifmw_nat64_appliance_memory: 2
39+
cifmw_nat64_appliance_cpus: 2
40+
cifmw_nat64_appliance_ssh_pub_key: "{{ ansible_user_dir }}/.ssh/id_rsa.pub"
41+
42+
cifmw_nat64_ipv6_prefix: "fd00:abcd:abcd:fc00::/64"
43+
cifmw_nat64_ipv6_tayga_address: "fd00:abcd:abcd:fc00::3"

roles/nat64_appliance/files/nat64-appliance.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
- block-device-efi
99
- package-installs
1010
- nat64-router
11+
- reset-bls-entries # Requires edpm-image-builder elements.
1112
environment:
1213
DIB_RELEASE: '9-stream'
1314
DIB_PYTHON_VERSION: '3'
1415
DIB_IMAGE_SIZE: '2'
1516
COMPRESS_IMAGE: '1'
16-
TMP_DIR: '/var/tmp'
1717
DIB_BLOCK_DEVICE_CONFIG: |
1818
- local_loop:
1919
name: image0
@@ -34,6 +34,16 @@
3434
- name: BSP
3535
type: 'EF02'
3636
size: 8MiB
37+
- name: boot
38+
type: '8300'
39+
size: 512MiB
40+
mkfs:
41+
type: xfs
42+
mount:
43+
mount_point: /boot
44+
fstab:
45+
options: "defaults"
46+
fsck-passno: 1
3747
- name: root
3848
type: '8300'
3949
size: 100%
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
- name: Cleanup
2+
hosts: instance
3+
vars:
4+
ansible_user_dir: "{{ lookup('env', 'HOME') }}"
5+
tasks:
6+
- name: "Destroy the test-node"
7+
community.libvirt.virt:
8+
command: destroy
9+
name: test-node
10+
uri: 'qemu:///system'
11+
12+
- name: "Undefine the test-node"
13+
community.libvirt.virt:
14+
command: undefine
15+
name: test-node
16+
force: true
17+
uri: 'qemu:///system'
18+
19+
- name: Destroy the test network
20+
register: net_destroy
21+
community.libvirt.virt_net:
22+
command: destroy
23+
name: br-mol
24+
uri: 'qemu:///system'
25+
failed_when:
26+
- net_destroy.rc is defined
27+
- net_destroy.rc > 1
28+
29+
- name: Undefine the test network
30+
community.libvirt.virt_net:
31+
command: undefine
32+
name: br-mol
33+
uri: 'qemu:///system'
34+
35+
- name: "Cleanup the nat64 appliance and networks"
36+
ansible.builtin.include_role:
37+
name: nat64_appliance
38+
tasks_from: cleanup.yml

0 commit comments

Comments
 (0)