ansible.builtin.serverless (v2.3.3.0-1) — module

Manages a Serverless Framework project

| "added in version" 2.3 of ansible.builtin"

Authors: Ryan Scott Brown @ryansb

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.3.3.0.post1

Description

Provides support for managing Serverless Framework (https://serverless.com/) project deployments and stacks.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Basic deploy of a service
- serverless:
    service_path: '{{ project_dir }}'
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Deploy specific functions
- serverless:
    service_path: '{{ project_dir }}'
    functions:
      - my_func_one
      - my_func_two
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# deploy a project, then pull its resource list back into Ansible
- serverless:
    stage: dev
    region: us-east-1
    service_path: '{{ project_dir }}'
  register: sls
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# The cloudformation stack is always named the same as the full service, so the
# cloudformation_facts module can get a full list of the stack resources, as
# well as stack events and outputs
- cloudformation_facts:
    region: us-east-1
    stack_name: '{{ sls.service_name }}'
    stack_resources: true

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - Goal state of given stage/project
    required: false

deploy:
    default: true
    description:
    - Whether or not to deploy artifacts after building them. When this option is `false`
      all the functions will be built, but no stack update will be run to send them out.
      This is mostly useful for generating artifacts to be stored/deployed elsewhere.
    required: false

region:
    default: us-east-1
    description:
    - AWS region to deploy the service to
    required: false

functions:
    default: []
    description:
    - A list of specific functions to deploy. If this is not provided, all functions in
      the service will be deployed.
    required: false

service_path:
    description:
    - The path to the root of the Serverless Service to be operated on.
    required: true

Outputs

command:
  description: Full `serverless` command run by this module, in case you want to re-run
    the command outside the module.
  returned: always
  sample: serverless deploy --stage production
  type: string
service_name:
  description: Most
  returned: always
  sample: my-fancy-service-dev
  type: string
state:
  description: Whether the stack for the serverless project is present/absent.
  returned: always
  type: string