Skip to content

Commit cca460c

Browse files
hjensasopenshift-merge-bot[bot]
authored andcommitted
nat64 - Fix molecule, and touch ups to stabilize
The molecule tests was failing because the interfaces did not end up in the 'libvirt' firewall zone. Added the zone attribute to the libvirt bridge element. This should work according to libvirt documentation, but for some reason not in this test environment. So, had to do that manually with firewalld. Also: * Pin dnsmasq to the v2.89 tag. Should be more stable than running of the main branch with frequent changes. * Set do-daemonize: no in unbound config. This removes a warning logged by the unbound service, do-daemonize and use-systemd should not be used togheter. There is a lot of "crude" debug info gathering added in the molecule tests, I think we should keep that around as is to make troubleshooting any potentital future issues in this job.
1 parent 4e3770f commit cca460c

File tree

9 files changed

+207
-4
lines changed

9 files changed

+207
-4
lines changed

docs/dictionary/en-custom.txt

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ fci
152152
fedoraproject
153153
fil
154154
fips
155+
firewalld
155156
flbxutz
156157
fmw
157158
fqdn

roles/nat64_appliance/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* `cifmw_nat64_appliance_workdir`: (String) Working directory. Defaults to `{{ cifmw_nat64_appliance_basedir }}/nat64_appliance`.
1111
* `cifmw_nat64_appliance_venv_dir`: (String) Python virtual environment directory. Defaults to `{{ cifmw_nat64_appliance_workdir }}/venv`.
1212
* `cifmw_nat64_libvirt_uri`: (String) The libvirt URI for the hypervisor to deploy on. Defaults to `qemu:///system`.
13+
* `cifmw_nat64_firewall_zone`: (String) The value for the firewalld `zone` attribute on the libvirt networks. Defaults to `libvirt`.
1314
* `cifmw_nat64_network_ipv4_name`: (String) Name of the nat64 IPv4 libvirt network. Defaults to: `nat64-net-v4`.
1415
* `cifmw_nat64_network_ipv4_bridge_name`: (String) Bridge name for the nat64 IPv4 libvirt network. Defaults to: `br-64v4`.
1516
* `cifmw_nat64_network_ipv4_address`: (String) IP address for the nat64 IPv4 libvirt network. Defaults to: `172.31.255.1`.

roles/nat64_appliance/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ cifmw_nat64_appliance_workdir: "{{ cifmw_nat64_appliance_basedir }}/nat64_applia
2222
cifmw_nat64_appliance_venv_dir: "{{ cifmw_nat64_appliance_workdir }}/venv"
2323

2424
cifmw_nat64_libvirt_uri: "qemu:///system"
25+
cifmw_nat64_firewall_zone: libvirt
2526
cifmw_nat64_network_ipv4_name: nat64-net-v4
2627
cifmw_nat64_network_ipv4_bridge_name: br-64v4
2728
cifmw_nat64_network_ipv4_address: 172.31.255.1

roles/nat64_appliance/files/elements/nat64-router/install.d/70-dnsmasq

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set -o pipefail
2121

2222
pushd /root
2323

24+
# TODO(hjensas): Make the branch (tag) configurable via variable.
2425
git clone --depth 1 --branch v2.89 git://thekelleys.org.uk/dnsmasq.git
2526

2627
pushd dnsmasq

roles/nat64_appliance/molecule/default/converge.yml

+172-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
hosts: instance
1919
vars:
2020
ansible_user_dir: "{{ lookup('env', 'HOME') }}"
21-
cifmw_basedir: "/opt/basedir"
21+
cifmw_basedir: "{{ ansible_user_dir }}/ci-framework-data"
2222
tasks:
2323
- name: Crate SSH keypair
2424
register: _test_key
@@ -27,6 +27,18 @@
2727
path: "{{ (ansible_user_dir, '.ssh/id_test') | path_join }}"
2828
type: "ecdsa"
2929

30+
- name: Enable forwarding in the libvirt zone
31+
become: true
32+
ansible.builtin.command:
33+
cmd: >-
34+
firewall-cmd --permanent --zone libvirt --add-forward
35+
36+
- name: Restart firewalld.service
37+
become: true
38+
ansible.builtin.systemd_service:
39+
name: firewalld
40+
state: restarted
41+
3042
- name: Discover latest image
3143
when:
3244
- cifmw_discovered_image_url is not defined
@@ -53,6 +65,15 @@
5365
ansible.builtin.include_role:
5466
name: nat64_appliance
5567

68+
- name: Fix permissions on logs dir - because we ran dib as root
69+
become: true
70+
ansible.builtin.file:
71+
path: "{{ cifmw_basedir }}/logs"
72+
state: directory
73+
recurse: true
74+
owner: "{{ ansible_user_id }}"
75+
group: "{{ ansible_user_gid }}"
76+
5677
- name: Fix permissions on nat64_appliance dir - because we ran dib as root
5778
become: true
5879
ansible.builtin.file:
@@ -82,7 +103,7 @@
82103
<network>
83104
<name>br-mol</name>
84105
<forward mode='open'/>
85-
<bridge name='br-mol' stp='on' delay='0'/>
106+
<bridge name='br-mol' zone='libvirt' stp='on' delay='0'/>
86107
<ip family='ipv6' address='2620:cf:cf:aaaa::1' prefix='64'/>
87108
<dns>
88109
<forwarder addr='2620:cf:cf:fc00::2'/>
@@ -108,6 +129,23 @@
108129
name: br-mol
109130
uri: 'qemu:///system'
110131

132+
# TODO(hjensas): With the zone set in libvirt XML this bridge "should"
133+
# already be in this zone. But logs indicate that it is not.
134+
# See: https://libvirt.org/formatnetwork.html
135+
- name: Make sure br-mol bridge is in the libvirt firewalld zone
136+
become: true
137+
ansible.posix.firewalld:
138+
zone: libvirt
139+
interface: br-mol
140+
state: enabled
141+
permanent: true
142+
143+
- name: Restart firewalld.service
144+
become: true
145+
ansible.builtin.systemd_service:
146+
name: firewalld
147+
state: restarted
148+
111149
- name: Generate test node UUID
112150
ansible.builtin.set_fact:
113151
test_node_uuid: "{{ 99999999 | random | to_uuid | lower }}"
@@ -261,18 +299,149 @@
261299
ansible.builtin.add_host:
262300
name: test-node
263301
groups:
264-
- test_nodes
302+
- testnodes
265303
ansible_host: '2620:cf:cf:aaaa::101'
266304
ansible_ssh_user: 'cloud-user'
267305
ansible_ssh_private_key_file: "{{ _test_key.filename }}"
268306
ansible_ssh_extra_args: '-o StrictHostKeyChecking=no'
269307

308+
- name: Add nat64 appliance to the invetory
309+
ansible.builtin.add_host:
310+
name: nat64-appliance
311+
groups:
312+
- nat64appliances
313+
ansible_host: '172.31.255.2'
314+
ansible_ssh_user: 'cloud-user'
315+
ansible_ssh_private_key_file: "{{ _test_key.filename }}"
316+
ansible_ssh_extra_args: '-o StrictHostKeyChecking=no'
317+
270318
# Even tough the node respond on port 22, let some time to ensure
271319
# ssh access for users is available.
272320
- name: Wait a little to let the test instance boot.
273321
ansible.builtin.pause:
274322
seconds: 20
275323

324+
- name: Run some commands to test the nat64-appliance DNS64 functions
325+
register: _nat64_appliance_dns64_debug
326+
ansible.builtin.shell: |
327+
echo "--- ping the DNS service listening address ---"
328+
ping -c 4 2620:cf:cf:fc00::2 || true
329+
echo
330+
echo "--- Try to resolve a name using 2620:cf:cf:fc00::2 ---"
331+
dig AAAA @2620:cf:cf:fc00::2 example.com
332+
echo
333+
echo "--- Try to resolve a name forwarding on test-network 2620:cf:cf:aaaa::1 ---"
334+
dig AAAA @2620:cf:cf:aaaa::1 example.com
335+
echo
336+
echo "--- Try to ping exmaple.com ---"
337+
ping -c 4 example.com || true
338+
339+
- name: Grab some info from the test node
340+
become: true
341+
delegate_to: test-node
342+
register: _test_node_debug_info
343+
ansible.builtin.shell: |
344+
echo "--- ip addr show ---"
345+
ip addr show
346+
echo
347+
echo "--- ip -6 route show ---"
348+
ip -6 route show
349+
echo
350+
echo "--- /etc/resolv.conf ---"
351+
cat /etc/resolv.conf
352+
echo
353+
echo "--- NetworkManager system-connections ---"
354+
for file in $(find /etc/NetworkManager/system-connections/ -type f); do
355+
echo "--- $file ---"
356+
cat $file
357+
echo
358+
done
359+
360+
- name: Grab some info from the nat64 appliance
361+
become: true
362+
delegate_to: nat64-appliance
363+
register: _nat64_appliance_debug_info
364+
ansible.builtin.shell: |
365+
echo "--- ip addr show ---"
366+
ip addr show
367+
echo
368+
echo "--- ip -4 route show ---"
369+
ip -4 route show
370+
echo
371+
echo "--- ip -6 route show ---"
372+
ip -6 route show
373+
echo
374+
echo "--- /etc/resolv.conf ---"
375+
cat /etc/resolv.conf
376+
echo
377+
echo "--- NetworkManager system-connections ---"
378+
for file in $(find /etc/NetworkManager/system-connections/ -type f); do
379+
echo "--- $file ---"
380+
cat $file
381+
echo
382+
done
383+
echo
384+
echo "--- systemctl status unbound.service ---"
385+
systemctl status unbound.service
386+
echo
387+
echo "--- systemctl status nat64-v4-dnsmasq.service ---"
388+
systemctl status nat64-v4-dnsmasq.service
389+
echo
390+
echo "--- systemctl status nat64-v6-dnsmasq.service ---"
391+
systemctl status nat64-v6-dnsmasq.service
392+
393+
- name: Grab the journal from the nat64 appliance
394+
become: true
395+
delegate_to: nat64-appliance
396+
register: _nat64_appliance_journal
397+
ansible.builtin.shell: |
398+
journalctl -b --no-pager
399+
400+
- name: Grab some info from hypervisor
401+
become: true
402+
delegate_to: instance
403+
register: _hypervisor_info
404+
ansible.builtin.shell: |
405+
echo "--- ip addr show ---"
406+
ip addr show
407+
echo
408+
echo "--- ip -4 route show ---"
409+
ip -4 route show
410+
echo
411+
echo "--- ip -6 route show ---"
412+
ip -6 route show
413+
echo
414+
echo "--- firewall - list-all-zones"
415+
firewall-cmd --list-all-zones
416+
echo
417+
echo "--- sysctl - list all"
418+
sysctl -a
419+
420+
- name: Write test-node info to file
421+
ansible.builtin.copy:
422+
dest: "{{ cifmw_basedir }}/logs/test_node_info.log"
423+
content: "{{ _test_node_debug_info.stdout }}"
424+
425+
- name: Write nat64-appliance info to file
426+
ansible.builtin.copy:
427+
dest: "{{ cifmw_basedir }}/logs/nat64_appliance_node_info.log"
428+
content: "{{ _nat64_appliance_debug_info.stdout }}"
429+
430+
- name: Write nat64-appliance journal to file
431+
ansible.builtin.copy:
432+
dest: "{{ cifmw_basedir }}/logs/nat64_appliance_journal.log"
433+
content: "{{ _nat64_appliance_journal.stdout }}"
434+
435+
- name: Write nat64-appliance DNS64 debug to file
436+
ansible.builtin.copy:
437+
dest: "{{ cifmw_basedir }}/logs/nat64_appliance_dns64_debug.log"
438+
content: "{{ _nat64_appliance_dns64_debug.stdout }}"
439+
440+
- name: Write hypervisor info to file
441+
ansible.builtin.copy:
442+
dest: "{{ cifmw_basedir }}/logs/hypervisor_info.log"
443+
content: "{{ _hypervisor_info.stdout }}"
444+
276445
- name: Ping example.com (delegate to test-node)
277446
delegate_to: test-node
278447
register: _ping_example_com

roles/nat64_appliance/molecule/default/prepare.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
- name: Prepare
1818
hosts: all
1919
vars:
20-
cifmw_basedir: "/opt/basedir"
20+
ansible_user_dir: "{{ lookup('env', 'HOME') }}"
21+
cifmw_basedir: "{{ ansible_user_dir }}/ci-framework-data"
2122
pre_tasks:
2223
- name: Create custom basedir
2324
become: true
@@ -27,6 +28,13 @@
2728
owner: zuul
2829
group: zuul
2930
mode: "0755"
31+
- name: Install some debug utils
32+
become: true
33+
ansible.builtin.package:
34+
name:
35+
- bind-utils
36+
- tcpdump
37+
state: present
3038
roles:
3139
- role: test_deps
3240
- role: libvirt_manager

roles/nat64_appliance/tasks/deploy.yml

+20
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@
5454
name: "{{ cifmw_nat64_network_ipv6_name }}"
5555
uri: "{{ cifmw_nat64_libvirt_uri }}"
5656

57+
# TODO(hjensas): With the zone set in libvirt XML these bridges "should"
58+
# already be in this zone. But logs indicate that they are not.
59+
# See: https://libvirt.org/formatnetwork.html
60+
- name: Make sure all bridges are in the libvirt firewalld zone
61+
become: true
62+
ansible.posix.firewalld:
63+
zone: "{{ cifmw_nat64_firewall_zone }}"
64+
interface: "{{ item }}"
65+
state: enabled
66+
permanent: true
67+
loop:
68+
- "{{ cifmw_nat64_network_ipv6_bridge_name }}"
69+
- "{{ cifmw_nat64_network_ipv4_bridge_name }}"
70+
71+
- name: Restart firewalld.service
72+
become: true
73+
ansible.builtin.systemd_service:
74+
name: firewalld
75+
state: restarted
76+
5777
- name: "Generate nat64-appliance UUID"
5878
ansible.builtin.set_fact:
5979
nat64_appliance_uuid: "{{ 99999999 | random | to_uuid | lower }}"

roles/nat64_appliance/templates/ipv4_network.xml.j2

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/>
66
<bridge
77
name='{{ cifmw_nat64_network_ipv4_bridge_name }}'
8+
zone='{{ cifmw_nat64_firewall_zone }}'
89
stp='on'
910
delay='0'
1011
/>

roles/nat64_appliance/templates/ipv6_network.xml.j2

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/>
66
<bridge
77
name='{{ cifmw_nat64_network_ipv6_bridge_name }}'
8+
zone='{{ cifmw_nat64_firewall_zone }}'
89
stp='on'
910
delay='0'
1011
/>

0 commit comments

Comments
 (0)