|
5 | 5 | tasks: |
6 | 6 | - name: Run tests |
7 | 7 | 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 | + |
8 | 36 | - name: Run role with no arguments to get provider |
9 | 37 | include_role: |
10 | 38 | name: linux-system-roles.timesync |
11 | 39 | public: true |
12 | 40 |
|
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 |
18 | 55 |
|
19 | 56 | - name: Try timesync_ntp_ip_family IPv4 |
20 | 57 | include_role: |
|
23 | 60 | timesync_ntp_ip_family: IPv4 |
24 | 61 |
|
25 | 62 | - name: Verify IPv4 setting |
26 | | - command: grep 'OPTIONS=.* -4' {{ __test_file }} |
| 63 | + command: grep 'OPTIONS=.* -4' {{ timesync_chrony_sysconfig_path }} |
27 | 64 | changed_when: false |
28 | 65 |
|
29 | 66 | - name: Try timesync_ntp_ip_family IPv6 |
|
33 | 70 | timesync_ntp_ip_family: IPv6 |
34 | 71 |
|
35 | 72 | - name: Verify IPv6 setting |
36 | | - command: grep 'OPTIONS=.* -6' {{ __test_file }} |
| 73 | + command: grep 'OPTIONS=.* -6' {{ timesync_chrony_sysconfig_path }} |
37 | 74 | changed_when: false |
38 | 75 |
|
39 | 76 | always: |
|
46 | 83 | - name: Verify reset |
47 | 84 | shell: | |
48 | 85 | 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 |
52 | 89 | exit 1 |
53 | 90 | fi |
54 | 91 | exit 0 |
|
0 commit comments