mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
In order to guarantee each test is cleaned up properly in the end, it is important to add a post-test check to each test checking that: - Routes and DNS are restored. - Network connectivity to certain hosts are preserved. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
39 lines
1 KiB
YAML
39 lines
1 KiB
YAML
# SPDX-License-Identifier: BSD-3-Clause
|
|
---
|
|
# This is typically used after cleanup, to verify that cleanup
|
|
# worked and left networking in the default state - sort of like
|
|
# a post-condition, or pre-condition for subsequent tests
|
|
- name: Check routes and DNS
|
|
shell: |
|
|
set -euo pipefail
|
|
echo IP
|
|
ip a
|
|
echo IP ROUTE
|
|
ip route
|
|
echo IP -6 ROUTE
|
|
ip -6 route
|
|
echo RESOLV
|
|
if [ -f /etc/resolv.conf ]; then
|
|
cat /etc/resolv.conf
|
|
else
|
|
echo NO /etc/resolv.conf
|
|
ls -alrtF /etc/resolv.* || :
|
|
fi
|
|
changed_when: false
|
|
|
|
- name: Verify DNS and network connectivity
|
|
shell: |
|
|
set -euo pipefail
|
|
echo CHECK DNS AND CONNECTIVITY
|
|
for host in mirrors.fedoraproject.org mirrors.centos.org; do
|
|
if ! getent hosts "$host"; then
|
|
echo FAILED to lookup host "$host"
|
|
exit 1
|
|
fi
|
|
if ! curl -o /dev/null https://"$host"; then
|
|
echo FAILED to contact host "$host"
|
|
exit 1
|
|
fi
|
|
done
|
|
when: ansible_facts["distribution"] == "CentOS"
|
|
changed_when: false
|