2 Commits

Author SHA1 Message Date
ef8c7e3381 Merge pull request 'Handle case of absent instance_config.yml gracefully' (#13) from improved-failure-handling into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #13
2021-06-28 14:28:14 +02:00
8bf5ca3ed2 Handle case of absent instance_config.yml gracefully
Some checks reported errors
continuous-integration/drone/pr Build was killed
continuous-integration/drone/push Build is passing
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.
2021-06-28 14:20:00 +02:00

View File

@ -6,16 +6,16 @@
no_log: "{{ molecule_no_log }}" no_log: "{{ molecule_no_log }}"
tasks: tasks:
- name: Populate the instance config - name: Populate the instance config
block: set_fact:
- name: Populate instance config from file instance_conf: "{{ lookup('file', molecule_instance_config, errors='warn') | from_yaml }}"
set_fact: skip_instances: false
instance_conf: "{{ lookup('file', molecule_instance_config) | from_yaml }}" register: instance_config_lookup
skip_instances: false
rescue: - name: Populate instance config when file missing
- name: Populate instance config when file missing set_fact:
set_fact: instance_conf: {}
instance_conf: {} skip_instances: true
skip_instances: true when: not instance_config_lookup.ansible_facts.instance_conf
- name: Destroy molecule instance(s) - name: Destroy molecule instance(s)
hcloud_server: hcloud_server: