From fa6514b6f7b68f8508b9960fa9a38a39f4d99e0a Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 11 Feb 2020 19:39:00 -0500 Subject: [PATCH] paunch: add "cleanup" parameter, useful for apply action Support the new option in Paunch which allows to not cleaning containers not part of a config. Also by security, if only one .json file is given in "config" parameter, we will force cleanup to false, to avoid the deletion of the other containers in the same config id. Change-Id: Ib9115be94b704072393c3c510e6158baddab2dc6 --- tripleo_ansible/ansible_plugins/modules/paunch.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tripleo_ansible/ansible_plugins/modules/paunch.py b/tripleo_ansible/ansible_plugins/modules/paunch.py index 84a5f50bf..41e051d7b 100644 --- a/tripleo_ansible/ansible_plugins/modules/paunch.py +++ b/tripleo_ansible/ansible_plugins/modules/paunch.py @@ -101,6 +101,11 @@ options: description: - Absolute path for the paunch log file. default: /var/log/paunch.log + cleanup: + description: + - Whether or not we cleanup containers not in config. Useful only for apply action. + type: bool + default: True """ EXAMPLES = """ @@ -112,6 +117,7 @@ EXAMPLES = """ haproxy: image: docker.io/tripleomaster/centos-binary-haproxy:current-tripleo-hotfix config_id: tripleo_step1 + cleanup: false action: apply # Paunch cleanup example - name: Cleanup containers for step 1 and step 2 @@ -141,6 +147,7 @@ class PaunchManager: self.healthcheck_disabled = \ self.module.params['healthcheck_disabled'] self.container_cli = self.module.params['container_cli'] + self.cleanup = self.module.params['cleanup'] self.config_overrides = self.module.params['config_overrides'] self.container_log_stdout_path = \ self.module.params['container_log_stdout_path'] @@ -159,6 +166,9 @@ class PaunchManager: log_file=self.log_file) if self.config: + if self.config.endswith('.json'): + self.module.warn('Only one config was given, cleanup disabled') + self.cleanup = False self.config_yaml = putils_common.load_config( self.config, overrides=self.config_overrides) @@ -187,7 +197,8 @@ class PaunchManager: log_level=self.log_level, log_file=self.log_file, cont_log_path=self.container_log_stdout_path, - healthcheck_disabled=self.healthcheck_disabled + healthcheck_disabled=self.healthcheck_disabled, + cleanup=self.cleanup ) stdout, stderr = ["\n".join(i) for i in (stdout_list, stderr_list)]