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
This commit is contained in:
Emilien Macchi 2020-02-20 08:51:03 -05:00
parent 57cc4d8075
commit a2c3a5c50b

View File

@ -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):