Skip to content

Commit 6ec44c3

Browse files
committed
test: add test for secccomp on el9/el10
Add a test to ensure that running the role with no variables does not remove the default OPTIONS for seccomp. This also required adding a vars file for Fedora Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 7853b0d commit 6ec44c3

File tree

2 files changed

+58
-10
lines changed

2 files changed

+58
-10
lines changed

tests/tests_options.yml

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,53 @@
55
tasks:
66
- name: Run tests
77
block:
8+
- name: Get vars needed to run the tests
9+
include_role:
10+
name: linux-system-roles.timesync
11+
public: true
12+
tasks_from: set_vars.yml
13+
14+
# install the provider to install the sysconfig file
15+
- name: Install chrony
16+
package:
17+
name: chrony
18+
state: present
19+
use: "{{ (__timesync_is_ostree | d(false)) |
20+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
21+
when: timesync_ntp_provider == 'chrony'
22+
23+
- name: Install ntp
24+
package:
25+
name: ntp
26+
state: present
27+
use: "{{ (__timesync_is_ostree | d(false)) |
28+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
29+
when: timesync_ntp_provider == 'ntp'
30+
31+
- name: Get OPTIONS before running
32+
command: grep ^OPTIONS= {{ timesync_chrony_sysconfig_path }}
33+
changed_when: false
34+
register: __timesync_config_before
35+
836
- name: Run role with no arguments to get provider
937
include_role:
1038
name: linux-system-roles.timesync
1139
public: true
1240

13-
- name: Set vars based on provider
14-
set_fact:
15-
__test_file: "{{ timesync_chrony_sysconfig_path
16-
if timesync_ntp_provider_current == 'chrony'
17-
else timesync_ntp_sysconfig_path }}"
41+
- name: Get OPTIONS after running
42+
command: grep ^OPTIONS= {{ timesync_chrony_sysconfig_path }}
43+
changed_when: false
44+
register: __timesync_config_after
45+
46+
- name: Show options
47+
debug:
48+
msg: |
49+
before [{{ __timesync_config_before.stdout }}]
50+
after [{{ __timesync_config_after.stdout }}]
51+
52+
- name: Ensure that OPTIONS did not change
53+
assert:
54+
that: __timesync_config_before.stdout == __timesync_config_after.stdout
1855

1956
- name: Try timesync_ntp_ip_family IPv4
2057
include_role:
@@ -23,7 +60,7 @@
2360
timesync_ntp_ip_family: IPv4
2461

2562
- name: Verify IPv4 setting
26-
command: grep 'OPTIONS=.* -4' {{ __test_file }}
63+
command: grep 'OPTIONS=.* -4' {{ timesync_chrony_sysconfig_path }}
2764
changed_when: false
2865

2966
- name: Try timesync_ntp_ip_family IPv6
@@ -33,7 +70,7 @@
3370
timesync_ntp_ip_family: IPv6
3471

3572
- name: Verify IPv6 setting
36-
command: grep 'OPTIONS=.* -6' {{ __test_file }}
73+
command: grep 'OPTIONS=.* -6' {{ timesync_chrony_sysconfig_path }}
3774
changed_when: false
3875

3976
always:
@@ -46,9 +83,9 @@
4683
- name: Verify reset
4784
shell: |
4885
set -eux
49-
if grep 'OPTIONS=.* -4' {{ __test_file }} || \
50-
grep 'OPTIONS=.* -6' {{ __test_file }}; then
51-
echo ERROR: {{ __test_file }} has incorrect OPTIONS
86+
if grep 'OPTIONS=.* -4' {{ timesync_chrony_sysconfig_path }} || \
87+
grep 'OPTIONS=.* -6' {{ timesync_chrony_sysconfig_path }}; then
88+
echo ERROR: {{ timesync_chrony_sysconfig_path }} has incorrect OPTIONS
5289
exit 1
5390
fi
5491
exit 0

vars/Fedora.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
timesync_ntp_provider_os_default: chrony
3+
timesync_chrony_dhcp_sourcedir: /run/chrony-dhcp
4+
timesync_chrony_sysconfig_path: /etc/sysconfig/chronyd
5+
timesync_chrony_sysconfig_options: "-F 2"
6+
timesync_chrony_conf_path: "/etc/chrony.conf"
7+
timesync_ntp_sysconfig_path: /etc/sysconfig/ntpd
8+
timesync_ptp4l_sysconfig_path: /etc/sysconfig/ptp4l
9+
timesync_phc2sys_sysconfig_path: /etc/sysconfig/phc2sys
10+
# wokeignore:rule=master
11+
timesync_timemaster_config_path: /etc/timemaster.conf

0 commit comments

Comments
 (0)