From 1e4121f5a418b4feba1a6f9bcaf4b6349b92d5b5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Thu, 5 Jul 2018 11:57:36 +0200 Subject: [PATCH] Allow inventories with no "properties" Without this patch, inventories with hosts without the field "properties" cannot be used. Currently, the group variable resolution will fail when parsing properties.is_metal, as properties wouldn't be defined. This is a problem, because it forces deployers with an external inventory to add a useless "properties" field for them. This patch solves the problem by simplifying the conditions, making them valid if the deployer has defined is_metal in its inventory or not. Change-Id: Ic09b455016dd3d4f7945900d13d37fdc86f80134 --- inventory/group_vars/all/all.yml | 5 ++++- inventory/group_vars/galera_all.yml | 2 +- inventory/group_vars/memcached.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/inventory/group_vars/all/all.yml b/inventory/group_vars/all/all.yml index ce72829580..7546e2e67f 100644 --- a/inventory/group_vars/all/all.yml +++ b/inventory/group_vars/all/all.yml @@ -127,4 +127,7 @@ ansible_ssh_extra_args: > -T # Toggle whether the service is deployed in a container or not -is_metal: "{{ properties.is_metal | default(false) }}" +is_metal: >- + {{ (properties is defined) and + (properties.is_metal is defined) and + (properties.is_metal | bool) }} diff --git a/inventory/group_vars/galera_all.yml b/inventory/group_vars/galera_all.yml index 08a8da382b..9bb3fd1051 100644 --- a/inventory/group_vars/galera_all.yml +++ b/inventory/group_vars/galera_all.yml @@ -25,7 +25,7 @@ galera_container_bind_mounts: # Disable PrivateDevices for MariaDB on CentOS 7 # See https://bugs.launchpad.net/openstack-ansible/+bug/1697531 for details. -galera_disable_privatedevices: "{{ ((properties.is_metal | default(false)) | bool) | ternary('false', 'true') }}" +galera_disable_privatedevices: "{{ not is_metal }}" # By default galera_monitoring xinetd app is open to 0.0.0.0/0 # This makes sure the monitoring is only restricted to the necessary nodes: diff --git a/inventory/group_vars/memcached.yml b/inventory/group_vars/memcached.yml index f6e861f079..98f062684b 100644 --- a/inventory/group_vars/memcached.yml +++ b/inventory/group_vars/memcached.yml @@ -20,4 +20,4 @@ memcached_package_state: "{{ package_state }}" # Disable PrivateDevices for MemcacheD on CentOS 7 # See https://bugs.launchpad.net/openstack-ansible/+bug/1697531 for details. -memcached_disable_privatedevices: "{{ ((properties.is_metal | default(false)) | bool) | ternary('false', 'true') }}" +memcached_disable_privatedevices: "{{ not is_metal }}"