[cloud] Adds custom serverless binary path option to the serverless module (#26304)

pull/22775/merge
Daniel Parker 7 years ago committed by Ryan Brown
parent 89be01f2a2
commit 800de2b0ce

@ -38,6 +38,11 @@ options:
- Goal state of given stage/project - Goal state of given stage/project
required: false required: false
default: present default: present
serverless_bin_path:
description:
- The path of a serverless framework binary relative to the 'service_path' eg. node_module/.bin/serverless
required: false
version_added: "2.4"
service_path: service_path:
description: description:
- The path to the root of the Serverless Service to be operated on. - The path to the root of the Serverless Service to be operated on.
@ -94,6 +99,13 @@ EXAMPLES = """
region: us-east-1 region: us-east-1
stack_name: '{{ sls.service_name }}' stack_name: '{{ sls.service_name }}'
stack_resources: true stack_resources: true
# Deploy a project but use a locally installed serverless binary instead of the global serverless binary
- serverless:
stage: dev
region: us-east-1
service_path: '{{ project_dir }}'
serverless_bin_path: node_modules/.bin/serverless
""" """
RETURN = """ RETURN = """
@ -153,6 +165,7 @@ def main():
region = dict(default='', required=False), region = dict(default='', required=False),
stage = dict(default='', required=False), stage = dict(default='', required=False),
deploy = dict(default=True, type='bool', required=False), deploy = dict(default=True, type='bool', required=False),
serverless_bin_path = dict(required=False, type='path')
), ),
) )
@ -162,8 +175,13 @@ def main():
region = module.params.get('region') region = module.params.get('region')
stage = module.params.get('stage') stage = module.params.get('stage')
deploy = module.params.get('deploy', True) deploy = module.params.get('deploy', True)
serverless_bin_path = module.params.get('serverless_bin_path')
if serverless_bin_path is not None:
command = serverless_bin_path + " "
else:
command = "serverless " command = "serverless "
if state == 'present': if state == 'present':
command += 'deploy ' command += 'deploy '
elif state == 'absent': elif state == 'absent':

Loading…
Cancel
Save