From 9812d6db736181067a7b5e1956bcea7398b3884d Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Tue, 19 Jul 2016 16:39:04 -0700 Subject: [PATCH] Fix deprecation warning for undefined variables 'with_' clauses are evaluated before 'when' clauses. In Ansible 1.9 the task is silently skipped when a variable within a 'with_' clause is undefined, Ansible 2 provides a deprecation warning. Separate the task deploying a user provided ssl cert and key into two and check them individually for 'haproxy_user_ssl_cert' or 'haproxy_user_ssl_key' being defined. Change-Id: I75367fe25d15d35ff60203b7c1d78437d613404d --- .../tasks/haproxy_ssl_configuration.yml | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/playbooks/roles/haproxy_server/tasks/haproxy_ssl_configuration.yml b/playbooks/roles/haproxy_server/tasks/haproxy_ssl_configuration.yml index 56715e0535..3c8728ecfa 100644 --- a/playbooks/roles/haproxy_server/tasks/haproxy_ssl_configuration.yml +++ b/playbooks/roles/haproxy_server/tasks/haproxy_ssl_configuration.yml @@ -13,19 +13,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Drop user provided ssl cert and key +- name: Deploy user provided ssl cert copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" + src: "{{ haproxy_user_ssl_cert }}" + dest: "{{ haproxy_ssl_cert }}" owner: "root" group: "root" - mode: "{{ item.mode }}" - with_items: - - { src: "{{ haproxy_user_ssl_cert }}", dest: "{{ haproxy_ssl_cert }}", mode: "0644" } - - { src: "{{ haproxy_user_ssl_key }}", dest: "{{ haproxy_ssl_key }}", mode: "0640" } - when: - - haproxy_user_ssl_cert is defined - - haproxy_user_ssl_key is defined + mode: "0644" + when: haproxy_user_ssl_cert is defined + notify: + - regen pem + tags: + - haproxy-ssl + +- name: Deploy user provided ssl key + copy: + src: "{{ haproxy_user_ssl_key }}" + dest: "{{ haproxy_ssl_key }}" + owner: "root" + group: "root" + mode: "0600" + when: haproxy_user_ssl_key is defined notify: - regen pem tags: