From a2c3a5c50b5ce8764074fb0f9f673c0519ff2a7e Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 20 Feb 2020 08:51:03 -0500 Subject: [PATCH] paunch: fail early if containers weren't deployed by Paunch before If an operator runs an update or upgrade of a cloud where containers were deployed by Ansible and not Paunch; and accidentally forget an environment file or a configuration somewhere (e.g. EnablePaunch); it might result of Paunch being called. To prevent that, Paunch will fail to run if /var/lib/tripleo-config/.ansible-managed file is detected; let's do the same in the Ansible module to fail early. Change-Id: I19c8d41cad860202351035e58fe336bb8577bcad --- tripleo_ansible/ansible_plugins/modules/paunch.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tripleo_ansible/ansible_plugins/modules/paunch.py b/tripleo_ansible/ansible_plugins/modules/paunch.py index 41e051d7b..8d117e6c9 100644 --- a/tripleo_ansible/ansible_plugins/modules/paunch.py +++ b/tripleo_ansible/ansible_plugins/modules/paunch.py @@ -137,6 +137,18 @@ class PaunchManager: self.module = module self.results = results + + # Fail early if containers were not deployed by Paunch before. + if os.path.isfile('/var/lib/tripleo-config/.ansible-managed'): + msg = ('Containers were previously deployed with ' + 'tripleo-ansible, paunch module can not be used. ' + 'Make sure EnablePaunch is set to False.') + self.module.fail_json( + msg=msg, + stdout='', + stderr='', + rc=1) + self.config = self.module.params['config'] if (isinstance(self.module.params['config_id'], list) and len(self.module.params['config_id']) == 1):