From 6999118fb6dbc13921f22ef611ae6e0e04e6c1a4 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 11 Jan 2021 10:06:08 +0100 Subject: [PATCH] validate: check virtual_ips variable This commit checks the length of `virtual_ips` doesn't exceed the length of `groups[rgwloadbalancer_group_name]`. It also ensure this variable is defined when `groups[rgwloadbalancer_group_name]` contains at least one node. Signed-off-by: Guillaume Abrioux (cherry picked from commit 3b63e0649cdaf322af1ad5a5b5b276ec9085d2d5) --- roles/ceph-validate/tasks/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/roles/ceph-validate/tasks/main.yml b/roles/ceph-validate/tasks/main.yml index 07c2e95e5..51c2fac28 100644 --- a/roles/ceph-validate/tasks/main.yml +++ b/roles/ceph-validate/tasks/main.yml @@ -225,3 +225,18 @@ - ceph_docker_registry_auth | bool - (ceph_docker_registry_username is not defined or ceph_docker_registry_password is not defined) or (ceph_docker_registry_username | length == 0 or ceph_docker_registry_password | length == 0) + +- name: check virtual_ips is defined + fail: + msg: "virtual_ips is not defined." + when: + - rgwloadbalancer_group_name in group_names + - groups[rgwloadbalancer_group_name] | length > 0 + - virtual_ips is not defined + +- name: validate virtual_ips length + fail: + msg: "There are more virual_ips defined than rgwloadbalancer nodes" + when: + - rgwloadbalancer_group_name in group_names + - (virtual_ips | length) > (groups[rgwloadbalancer_group_name] | length)