From 7a4517a067ffa5905bafb815c6a2b353d658ecbc Mon Sep 17 00:00:00 2001 From: ssemyonov Date: Fri, 10 Aug 2018 17:30:36 +0100 Subject: [PATCH] Introduce `force` and `verbose` options in serverless module (#43947) * Introduce `force` and `verbose` options in serverless module * Add "version_added: 2.7" for the new `force` and `verbose` options --- lib/ansible/modules/cloud/misc/serverless.py | 28 +++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/misc/serverless.py b/lib/ansible/modules/cloud/misc/serverless.py index 044e788242..6ebebf66df 100644 --- a/lib/ansible/modules/cloud/misc/serverless.py +++ b/lib/ansible/modules/cloud/misc/serverless.py @@ -56,6 +56,18 @@ options: run to send them out. This is mostly useful for generating artifacts to be stored/deployed elsewhere. required: false default: true + force: + description: + - Whether or not to force full deployment, equivalent to serverless `--force` option. + required: false + default: false + version_added: "2.7" + verbose: + description: + - Shows all stack events during deployment, and display any Stack Output. + required: false + default: false + version_added: "2.7" notes: - Currently, the `serverless` command must be in the path of the node executing the task. In the future this may be a flag. requirements: [ "serverless", "yaml" ] @@ -160,7 +172,9 @@ def main(): region=dict(default='', required=False), stage=dict(default='', required=False), deploy=dict(default=True, type='bool', required=False), - serverless_bin_path=dict(required=False, type='path') + serverless_bin_path=dict(required=False, type='path'), + force=dict(default=False, required=False), + verbose=dict(default=False, required=False) ), ) @@ -173,6 +187,8 @@ def main(): region = module.params.get('region') stage = module.params.get('stage') deploy = module.params.get('deploy', True) + force = module.params.get('force', False) + verbose = module.params.get('verbose', False) serverless_bin_path = module.params.get('serverless_bin_path') if serverless_bin_path is not None: @@ -187,12 +203,18 @@ def main(): else: module.fail_json(msg="State must either be 'present' or 'absent'. Received: {}".format(state)) - if not deploy and state == 'present': - command += '--noDeploy ' + if state == 'present': + if not deploy: + command += '--noDeploy ' + elif force: + command += '--force ' + if region: command += '--region {} '.format(region) if stage: command += '--stage {} '.format(stage) + if verbose: + command += '--verbose ' rc, out, err = module.run_command(command, cwd=service_path) if rc != 0: