From 773dc541dddb1c0e27172adddbd34c65afbe0b4f Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Wed, 21 Sep 2016 07:34:24 -0700 Subject: [PATCH] Fix deprecation warning for undefined variables Provide a default empty variable for 'extra_container_config'. Tasks which make use of this variable within with_items lists have been updated to evaluate that it has been set before executing. 'with_' clauses are evaluated before 'when' clauses. In Ansible 1.9 tasks are silently skipped when a variable within a 'with_' clause is undefined, Ansible 2 provides a deprecation warning. Change-Id: I3acd16a739cbdbed84d8d74de2b78b52577d4ee2 --- playbooks/common-tasks/os-lxc-container-setup.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/playbooks/common-tasks/os-lxc-container-setup.yml b/playbooks/common-tasks/os-lxc-container-setup.yml index 2e3523840a..1d9a67cc3b 100644 --- a/playbooks/common-tasks/os-lxc-container-setup.yml +++ b/playbooks/common-tasks/os-lxc-container-setup.yml @@ -80,12 +80,10 @@ line: "{{ item.split('=')[0] }} = {{ item.split('=', 1)[1] }}" insertafter: "^{{ item.split('=')[0] }}" backup: "true" - with_items: "{{ extra_container_config }}" + with_items: "{{ extra_container_config | default([]) }}" delegate_to: "{{ physical_host }}" register: _ec - when: - - extra_container_config is defined - - not is_metal | bool + when: not is_metal | bool # Due to https://github.com/ansible/ansible-modules-extras/issues/2691 # this uses the LXC CLI tools to ensure that we get logging.