From bd53c2d502085481c572b97ef2da322a479acb09 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 3 Oct 2020 16:59:36 +0200 Subject: [PATCH] fix syntax issue --- molecule/centos7/destroy.yml | 18 ++++-------------- molecule/centos8/destroy.yml | 18 ++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/molecule/centos7/destroy.yml b/molecule/centos7/destroy.yml index b78d10c..0037b35 100644 --- a/molecule/centos7/destroy.yml +++ b/molecule/centos7/destroy.yml @@ -6,16 +6,9 @@ no_log: "{{ molecule_no_log }}" tasks: - name: Populate the instance config - block: - - name: Populate instance config from file - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true + set_fact: + instance_conf_file: "{{ lookup('file', molecule_instance_config, errors='ignore') | from_yaml }}" + instance_conf: "{{ instance_conf_file | default([]) }}" - name: Destroy molecule instance(s) hcloud_server: @@ -24,7 +17,6 @@ state: absent register: server loop: "{{ instance_conf }}" - when: not skip_instances async: 7200 poll: 0 @@ -61,9 +53,7 @@ hcloud_ssh_key: name: "{{ instance_conf[0].ssh_key_name }}" state: absent - when: - - not skip_instances - - (instance_conf | default([])) | length > 0 # must contain at least one instance + when: (instance_conf | default([])) | length > 0 # Mandatory configuration for Molecule to function. diff --git a/molecule/centos8/destroy.yml b/molecule/centos8/destroy.yml index b78d10c..0037b35 100644 --- a/molecule/centos8/destroy.yml +++ b/molecule/centos8/destroy.yml @@ -6,16 +6,9 @@ no_log: "{{ molecule_no_log }}" tasks: - name: Populate the instance config - block: - - name: Populate instance config from file - set_fact: - instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" - skip_instances: false - rescue: - - name: Populate instance config when file missing - set_fact: - instance_conf: {} - skip_instances: true + set_fact: + instance_conf_file: "{{ lookup('file', molecule_instance_config, errors='ignore') | from_yaml }}" + instance_conf: "{{ instance_conf_file | default([]) }}" - name: Destroy molecule instance(s) hcloud_server: @@ -24,7 +17,6 @@ state: absent register: server loop: "{{ instance_conf }}" - when: not skip_instances async: 7200 poll: 0 @@ -61,9 +53,7 @@ hcloud_ssh_key: name: "{{ instance_conf[0].ssh_key_name }}" state: absent - when: - - not skip_instances - - (instance_conf | default([])) | length > 0 # must contain at least one instance + when: (instance_conf | default([])) | length > 0 # Mandatory configuration for Molecule to function.