From e82a3b1621e6191c67d749cb948dfe0cc91e714f Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Thu, 22 Aug 2024 16:11:37 +0200 Subject: [PATCH] chrony: check min number of servers (#1554) Signed-off-by: Christian Berendt --- roles/chrony/defaults/main.yml | 2 ++ roles/chrony/tasks/main.yml | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/roles/chrony/defaults/main.yml b/roles/chrony/defaults/main.yml index 4ec8e5418..713f46a1c 100644 --- a/roles/chrony/defaults/main.yml +++ b/roles/chrony/defaults/main.yml @@ -31,3 +31,5 @@ chrony_bind_local_interfaces_only: true # Bind Chrony to specific addresses # NOTE: It is only possible to set at most one IPv4 and one IPv6 address. chrony_bindaddresses: [] + +chrony_minimum_number_of_servers: 2 diff --git a/roles/chrony/tasks/main.yml b/roles/chrony/tasks/main.yml index 4fa33b02f..b31a400e2 100644 --- a/roles/chrony/tasks/main.yml +++ b/roles/chrony/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: Check minimum and maximum number of servers + ansible.builtin.fail: + msg: > + A minimum of {{ chrony_minimum_number_of_servers }} of server(s) must + be configured. Currently {{ chrony_servers | length }} server(s) are + configured. + when: chrony_servers | length < chrony_minimum_number_of_servers | int + - name: Gather variables for each operating system ansible.builtin.include_vars: "{{ ansible_os_family }}-family.yml"