Skip to content

Commit 4e2dd39

Browse files
authored
more ansible-lint 6.x fixes (#168)
* more ansible-lint 6.x fixes * ensure ethtool is installed where needed
1 parent a7102c0 commit 4e2dd39

29 files changed

+271
-160
lines changed

.ansible-lint

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
---
2+
profile: production
23
skip_list:
34
- fqcn-builtins
5+
exclude_paths:
6+
- tests/roles/
7+
- .github/
8+
- examples/roles/
9+
kinds:
10+
- yaml: "**/meta/collection-requirements.yml"
11+
- yaml: "**/tests/collection-requirements.yml"
12+
- playbook: "**/tests/tests_*.yml"
13+
- playbook: "**/tests/setup-snapshot.yml"
14+
- tasks: "**/tests/*.yml"
15+
- playbook: "**/tests/playbooks/*.yml"
16+
- tasks: "**/tests/tasks/*.yml"
17+
- tasks: "**/tests/tasks/*/*.yml"
18+
- vars: "**/tests/vars/*.yml"
19+
- playbook: "**/examples/*.yml"
20+
mock_roles:
21+
- linux-system-roles.timesync
22+
extra_vars:
23+
targets: target_hosts

README.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ timesync_ntp_servers:
2929
- hostname: foo.example.com # Hostname or address of the server
3030
minpoll: 4 # Minimum polling interval (default 6)
3131
maxpoll: 8 # Maximum polling interval (default 10)
32-
iburst: yes # Flag enabling fast initial synchronization
33-
# (default no)
34-
pool: no # Flag indicating that each resolved address
32+
iburst: true # Flag enabling fast initial synchronization
33+
# (default false)
34+
pool: false # Flag indicating that each resolved address
3535
# of the hostname is a separate NTP server
36-
# (default no)
37-
nts: no # Flag enabling Network Time Security (NTS)
38-
# authentication mechanism (default no,
36+
# (default false)
37+
nts: false # Flag enabling Network Time Security (NTS)
38+
# authentication mechanism (default false,
3939
# supported only with chrony >= 4.0)
40-
prefer: no # Flag marking the source to be preferred for
40+
prefer: false # Flag marking the source to be preferred for
4141
# synchronization over other sources
42-
# (default no)
43-
trust: no # Flag marking the source to be trusted over
42+
# (default false)
43+
trust: false # Flag marking the source to be trusted over
4444
# sources that don't have this flag
45-
# (default no)
46-
xleave: no # Flag enabling interleaved mode (default no)
45+
# (default false)
46+
xleave: false # Flag enabling interleaved mode (default false)
4747
filter: 1 # Number of NTP measurements per clock update
4848
# (default 1)
4949

5050
# List of PTP domains
5151
timesync_ptp_domains:
5252
- number: 0 # PTP domain number
53-
interfaces: [ eth0 ] # List of interfaces in the domain
53+
interfaces: [eth0] # List of interfaces in the domain
5454
delay: 0.000010 # Assumed maximum network delay to the
5555
# grandmaster in seconds
5656
# (default 100 microsecond)
5757
transport: UDPv4 # Network transport: UDPv4, UDPv6, L2
5858
# (default UDPv4)
5959
udp_ttl: 1 # TTL for UDPv4 and UDPv6 transports
6060
# (default 1)
61-
hybrid_e2e: no # Flag enabling unicast end-to-end delay
62-
# requests (default no)
61+
hybrid_e2e: false # Flag enabling unicast end-to-end delay
62+
# requests (default false)
6363

64-
# Flag enabling use of NTP servers provided by DHCP (default no)
65-
timesync_dhcp_ntp_servers: no
64+
# Flag enabling use of NTP servers provided by DHCP (default false)
65+
timesync_dhcp_ntp_servers: false
6666

6767
# Minimum offset of the clock which can be corrected by stepping (default is
6868
# specific to NTP/PTP implementation: chrony 1.0, ntp 0.128, linuxptp 0.00002).
@@ -80,21 +80,21 @@ timesync_min_sources: 1
8080
# List of interfaces which should have hardware timestamping enabled for NTP
8181
# (default empty list). As a special value, '*' enables the timestamping on all
8282
# interfaces that support it.
83-
timesync_ntp_hwts_interfaces: [ '*' ]
83+
timesync_ntp_hwts_interfaces: ["*"]
8484

8585
# Name of the package which should be installed and configured for NTP.
8686
# Possible values are "chrony" and "ntp". If not defined, the currently active
8787
# or enabled service will be configured. If no service is active or enabled, a
8888
# package specific to the system and its version will be selected.
8989
timesync_ntp_provider: chrony
9090

91-
# Sometimes administrators might need extended configurations for chrony which
92-
# are not covered by the predefined settings provided by this role.
93-
# 'timesync_chrony_custom_settings' allows to define a list of custom settings
94-
# for the chrony.conf file, by providing a list of settings. As an example,
91+
# Sometimes administrators might need extended configurations for chrony which
92+
# are not covered by the predefined settings provided by this role.
93+
# 'timesync_chrony_custom_settings' allows to define a list of custom settings
94+
# for the chrony.conf file, by providing a list of settings. As an example,
9595
# for debugging, one might need to log mesurements, statistics and tracking.
96-
# This information is usually stored in the /var/log/chrony directory. For
97-
# that, one needs to define two different settings (logdir and log), as
96+
# This information is usually stored in the /var/log/chrony directory. For
97+
# that, one needs to define two different settings (logdir and log), as
9898
# follows:
9999
timesync_chrony_custom_settings:
100100
- "logdir /var/log/chrony"
@@ -111,11 +111,11 @@ Install and configure ntp to synchronize the system clock with three NTP servers
111111
vars:
112112
timesync_ntp_servers:
113113
- hostname: foo.example.com
114-
iburst: yes
114+
iburst: true
115115
- hostname: bar.example.com
116-
iburst: yes
116+
iburst: true
117117
- hostname: baz.example.com
118-
iburst: yes
118+
iburst: true
119119
roles:
120120
- linux-system-roles.timesync
121121
```
@@ -128,7 +128,7 @@ grandmaster in PTP domain number 0, which is accessible on interface eth0:
128128
vars:
129129
timesync_ptp_domains:
130130
- number: 0
131-
interfaces: [ eth0 ]
131+
interfaces: [eth0]
132132
roles:
133133
- linux-system-roles.timesync
134134
```
@@ -149,19 +149,19 @@ synchronization:
149149
maxpoll: 6
150150
timesync_ptp_domains:
151151
- number: 0
152-
interfaces: [ eth0, eth1 ]
152+
interfaces: [eth0, eth1]
153153
transport: L2
154154
delay: 0.000010
155155
- number: 1
156-
interfaces: [ eth2 ]
156+
interfaces: [eth2]
157157
transport: UDPv4
158158
delay: 0.000010
159159
roles:
160160
- linux-system-roles.timesync
161161
```
162162
163-
Install and configure chrony with multiple NTP servers and custom advanced
164-
settings: log `measurements`,`statistics` and `tracking`
163+
Install and configure chrony with multiple NTP servers and custom advanced
164+
settings: log `measurements`, `statistics` and `tracking`
165165
into `/var/log/chrony`:
166166

167167

defaults/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ timesync_dhcp_ntp_servers: false
55
timesync_step_threshold: -1.0
66
timesync_min_sources: 1
77
timesync_ntp_hwts_interfaces: []
8-
timesync_ntp_provider: ''
8+
timesync_ntp_provider: ""
99
timesync_max_distance: 0

examples/multiple-ntp-servers.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- hosts: "{{ target }}"
2+
- name: Example with multiple servers
3+
hosts: "{{ targets }}"
34
vars:
45
timesync_ntp_servers:
56
- hostname: 0.pool.ntp.org

examples/single-pool.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- hosts: "{{ targets }}"
2+
- name: Example with single pool
3+
hosts: "{{ targets }}"
34
vars:
45
timesync_ntp_servers:
56
- hostname: 2.pool.ntp.org

tests/setup-snapshot.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- hosts: all
2+
- name: Setup snapshot
3+
hosts: all
34
tasks:
45
- name: Set platform/version specific variables
56
include_role:
@@ -15,7 +16,7 @@
1516
- linuxptp
1617
state: present
1718
no_log: true
18-
ignore_errors: true
19+
ignore_errors: true # noqa ignore-errors
1920

2021
- name: Uninstall test packages
2122
package:

tests/tests_chrony.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
- name: Run chrony tests
2727
tags: tests::verify
2828
block:
29-
- meta: flush_handlers
29+
- name: Flush handlers
30+
meta: flush_handlers
3031

3132
- name: Wait for services to start
3233
wait_for:
@@ -35,6 +36,7 @@
3536
- name: Get list of currently used time sources
3637
shell: chronyc -n sources || ntpq -pn
3738
register: sources
39+
changed_when: false
3840

3941
- name: Check time sources
4042
assert:
@@ -44,8 +46,9 @@
4446
- "'172.16.123.3' in sources.stdout"
4547

4648
- name: Get list of log files
47-
shell: ls /var/log/chrony/
49+
command: ls /var/log/chrony/
4850
register: logfiles
51+
changed_when: false
4952

5053
- name: Check log generated files
5154
assert:

tests/tests_default.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
- name: Ensure that the role runs with default parameters
33
hosts: all
4-
4+
gather_facts: false
55
roles:
66
- linux-system-roles.timesync
7-
gather_facts: false

tests/tests_default_vars.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
- name: Ensure that the role declares all parameters in defaults
33
hosts: all
4-
54
tasks:
6-
- name: include the timesync role
5+
- name: Include the timesync role
76
include_role:
87
name: linux-system-roles.timesync
98
public: true
109

11-
- name: check that public vars are defined
10+
- name: Check that public vars are defined
1211
assert:
1312
that: vars[item] is defined
1413
loop:

tests/tests_default_wrapper.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- 'tests::slow'
55
hosts: all
66
tasks:
7-
- name: create temporary file
7+
- name: Create temporary file
88
tempfile:
99
state: file
1010
suffix: .inventory.yaml
@@ -37,7 +37,7 @@
3737
vars:
3838
__ap_cmd: "{{ ansible_playbook_filepath | d('ansible-playbook') }}"
3939

40-
- name: remove the temporary file
40+
- name: Remove the temporary file
4141
file:
4242
path: "{{ tempinventory.path }}"
4343
state: absent

tests/tests_ntp.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
timesync_step_threshold: 0.01
2222
timesync_dhcp_ntp_servers: true
2323
timesync_min_sources: 2
24-
timesync_ntp_hwts_interfaces: ['*']
24+
timesync_ntp_hwts_interfaces: ["*"]
2525
roles:
2626
- linux-system-roles.timesync
2727

2828
tasks:
29-
- block:
30-
- meta: flush_handlers
29+
- name: Run test
30+
tags: tests::verify
31+
block:
32+
- name: Flush handlers
33+
meta: flush_handlers
3134

3235
- name: Wait for services to start
3336
wait_for:
@@ -36,6 +39,7 @@
3639
- name: Get list of currently used time sources
3740
shell: chronyc -n sources || ntpq -pn
3841
register: sources
42+
changed_when: false
3943

4044
- name: Check time sources
4145
assert:
@@ -105,4 +109,3 @@
105109
- ntp_conf is not search('172\.16\.123\.2.*true')
106110
- ntp_conf is search('172\.16\.123\.3.*true')
107111
when: ntp_conf is defined
108-
tags: tests::verify

tests/tests_ntp_provider1.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,32 @@
88
- linux-system-roles.timesync
99

1010
pre_tasks:
11-
- block:
11+
- name: Remove provider packages
12+
check_mode: false
13+
tags: tests::setup
14+
block:
1215
- name: Remove NTP providers
13-
package: name={{ item }} state=absent
16+
package:
17+
name: "{{ item }}"
18+
state: absent
1419
with_items:
1520
- chrony
1621
- ntp
17-
check_mode: false
18-
tags: tests::setup
1922

2023
post_tasks:
21-
- block:
24+
- name: Verify provider is working
25+
tags: tests::verify
26+
block:
2227
- name: Wait for services to start
2328
wait_for:
2429
timeout: 2
2530

2631
- name: Get list of currently used time sources
2732
shell: chronyc -n sources || ntpq -pn
2833
register: sources
34+
changed_when: false
2935

3036
- name: Check time sources
3137
assert:
3238
that:
3339
- "'172.16.123.1' in sources.stdout"
34-
tags: tests::verify

tests/tests_ntp_provider2.yml

+22-11
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,40 @@
88
- linux-system-roles.timesync
99

1010
pre_tasks:
11-
- block:
11+
- name: Remove the install ntp
12+
check_mode: false
13+
tags: tests::setup
14+
block:
1215
- name: Remove ntp
13-
package: name=ntp state=absent
16+
package:
17+
name: ntp
18+
state: absent
1419

1520
- name: Install chrony
16-
package: name=chrony state=present
21+
package:
22+
name: chrony
23+
state: present
1724
register: package_install
18-
ignore_errors: true
25+
ignore_errors: true # noqa ignore-errors
1926

20-
- meta: end_play
27+
- name: Skip test if no package
28+
meta: end_play
2129
when: package_install.failed
2230

2331
- name: Enable chronyd
24-
service: name=chronyd state=started enabled=yes
25-
check_mode: false
26-
tags: tests::setup
32+
service:
33+
name: chronyd
34+
state: started
35+
enabled: true
2736

2837
post_tasks:
29-
- block:
38+
- name: Verify chronyd running
39+
tags: tests::verify
40+
block:
3041
- name: Wait for services to start
3142
wait_for:
3243
timeout: 2
3344

3445
- name: Check chronyd service
35-
shell: chronyc -n tracking
36-
tags: tests::verify
46+
command: chronyc -n tracking
47+
changed_when: false

0 commit comments

Comments
 (0)