Handle case of absent instance_config.yml gracefully
continuous-integration/drone/pr Build was killed Details
continuous-integration/drone/push Build is passing Details

i.e., instead of throwing a red fatal error message at the user and
recovering with a rescue block we downgrade the lookup error to a
warning and set the same defaults in that case that were set in the
rescue block before.

See https://github.com/ansible-community/molecule-hetznercloud/issues/31.
This commit is contained in:
Benjamin Wenzel 2021-06-28 13:42:09 +02:00 committed by decentral1se
parent 6427696ce4
commit 8bf5ca3ed2
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 10 additions and 10 deletions

View File

@ -6,16 +6,16 @@
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) | from_yaml }}"
skip_instances: false
rescue:
- name: Populate instance config when file missing
set_fact:
instance_conf: {}
skip_instances: true
set_fact:
instance_conf: "{{ lookup('file', molecule_instance_config, errors='warn') | from_yaml }}"
skip_instances: false
register: instance_config_lookup
- name: Populate instance config when file missing
set_fact:
instance_conf: {}
skip_instances: true
when: not instance_config_lookup.ansible_facts.instance_conf
- name: Destroy molecule instance(s)
hcloud_server: