From 9ef7072d8eb889fa6fd8d0402eb5f0bea4e606f8 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 8 Oct 2019 15:50:55 +1100 Subject: [PATCH] autocluster: Do not run destroy if generated config does not exist When build is run, skip destroy if the file doesn't exist. This avoids a failure on the initial run. Error when destroy is run explicitly, since the error from Vagrant is very vague. Signed-off-by: Martin Schwenke --- autocluster.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autocluster.py b/autocluster.py index 985979b..25bd606 100755 --- a/autocluster.py +++ b/autocluster.py @@ -616,6 +616,10 @@ def cluster_destroy(cluster): announce('cluster', cluster, 'destroy') + config_file = get_config_file_path(cluster) + if not os.path.exists(config_file): + sys.exit('ERROR: Generated configuration for cluster does not exist') + cluster_destroy_quiet(cluster) @@ -680,7 +684,9 @@ def cluster_setup(cluster): def cluster_build(cluster): '''Build cluster using Ansible''' - cluster_destroy(cluster) + config_file = get_config_file_path(cluster) + if os.path.exists(config_file): + cluster_destroy(cluster) cluster_generate(cluster) cluster_create(cluster) cluster_ssh_config(cluster) -- 2.34.1