ansible / ansible.builtin / v2.4.3.0-1 / module / cloudformation Create or delete an AWS CloudFormation stack | "added in version" 1.1 of ansible.builtin" Authors: James S. Martin (@jsmartin) stableinterface | supported by coreansible.builtin.cloudformation (v2.4.3.0-1) — module
pip
Install with pip install ansible==2.4.3.0.post1
Launches or updates an AWS CloudFormation stack and waits for it complete.
# Basic task example - name: launch ansible cloudformation example cloudformation: stack_name: "ansible-cloudformation" state: "present" region: "us-east-1" disable_rollback: true template: "files/cloudformation-example.json" template_parameters: KeyName: "jmartin" DiskType: "ephemeral" InstanceType: "m1.small" ClusterSize: 3 tags: Stack: "ansible-cloudformation"
# Basic role example - name: launch ansible cloudformation example cloudformation: stack_name: "ansible-cloudformation" state: "present" region: "us-east-1" disable_rollback: true template: "roles/cloudformation/files/cloudformation-example.json" template_parameters: KeyName: "jmartin" DiskType: "ephemeral" InstanceType: "m1.small" ClusterSize: 3 tags: Stack: "ansible-cloudformation"
# Removal example - name: tear down old deployment cloudformation: stack_name: "ansible-cloudformation-old" state: "absent"
# Use a template from a URL - name: launch ansible cloudformation example cloudformation: stack_name: "ansible-cloudformation" state: present region: us-east-1 disable_rollback: true template_url: https://s3.amazonaws.com/my-bucket/cloudformation.template args: template_parameters: KeyName: jmartin DiskType: ephemeral InstanceType: m1.small ClusterSize: 3 tags: Stack: ansible-cloudformation
# Use a template from a URL, and assume a role to execute - name: launch ansible cloudformation example with role assumption cloudformation: stack_name: "ansible-cloudformation" state: present region: us-east-1 disable_rollback: true template_url: https://s3.amazonaws.com/my-bucket/cloudformation.template role_arn: 'arn:aws:iam::123456789012:role/cloudformation-iam-role' args: template_parameters: KeyName: jmartin DiskType: ephemeral InstanceType: m1.small ClusterSize: 3 tags: Stack: ansible-cloudformation
tags: default: null description: - Dictionary of tags to associate with stack and its resources during stack creation. Can be updated later, updating tags removes previous entries. required: false version_added: '1.4' version_added_collection: ansible.builtin state: description: - If state is "present", stack will be created. If state is "present" and if stack exists and template has changed, it will be updated. If state is "absent", stack will be removed. required: true region: aliases: - aws_region - ec2_region description: - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) type: str profile: aliases: - aws_profile description: - The I(profile) option is mutually exclusive with the I(aws_access_key), I(aws_secret_key) and I(security_token) options. type: str role_arn: default: null description: - The role that AWS CloudFormation assumes to create the stack. See the AWS CloudFormation Service Role docs U(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-servicerole.html) required: false version_added: '2.3' version_added_collection: ansible.builtin template: default: null description: - The local path of the cloudformation template. - This must be the full path to the file, relative to the working directory. If using roles this may look like "roles/cloudformation/files/cloudformation-example.json". - If 'state' is 'present' and the stack does not exist yet, either 'template' or 'template_url' must be specified (but not both). If 'state' is present, the stack does exist, and neither 'template' nor 'template_url' are specified, the previous template will be reused. required: false aws_config: description: - A dictionary to modify the botocore configuration. - Parameters can be found at U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config). type: dict stack_name: description: - name of the cloudformation stack required: true endpoint_url: aliases: - ec2_url - aws_endpoint_url - s3_url description: - URL to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used. type: str stack_policy: default: null description: - the path of the cloudformation stack policy. A policy cannot be removed once placed, but it can be modified. (for instance, [allow all updates](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html#d0e9051) required: false version_added: '1.9' version_added_collection: ansible.builtin template_url: description: - Location of file containing the template body. The URL must point to a template (max size 307,200 bytes) located in an S3 bucket in the same region as the stack. - If 'state' is 'present' and the stack does not exist yet, either 'template' or 'template_url' must be specified (but not both). If 'state' is present, the stack does exist, and neither 'template' nor 'template_url' are specified, the previous template will be reused. required: false version_added: '2.0' version_added_collection: ansible.builtin aws_ca_bundle: description: - The location of a CA Bundle to use when validating SSL certificates. - 'Note: The CA Bundle is read ''module'' side and may need to be explicitly copied from the controller if not run locally.' type: path aws_access_key: aliases: - ec2_access_key - access_key description: - C(AWS access key). If not set then the value of the C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY) or C(EC2_ACCESS_KEY) environment variable is used. - The I(aws_access_key) and I(profile) options are mutually exclusive. type: str aws_secret_key: aliases: - ec2_secret_key - secret_key description: - C(AWS secret key). If not set then the value of the C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY), or C(EC2_SECRET_KEY) environment variable is used. - The I(aws_secret_key) and I(profile) options are mutually exclusive. type: str changeset_name: default: null description: - Name given to the changeset when creating a changeset, only used when create_changeset is true. By default a name prefixed with Ansible-STACKNAME is generated based on input parameters. See the AWS Change Sets docs U(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html) required: false version_added: '2.4' version_added_collection: ansible.builtin security_token: aliases: - aws_session_token - session_token - aws_security_token - access_token description: - C(AWS STS security token). If not set then the value of the C(AWS_SECURITY_TOKEN) or C(EC2_SECURITY_TOKEN) environment variable is used. - The I(security_token) and I(profile) options are mutually exclusive. - Aliases I(aws_session_token) and I(session_token) have been added in version 3.2.0. type: str validate_certs: default: true description: - When set to "no", SSL certificates will not be validated for communication with the AWS APIs. type: bool template_format: choices: - json - yaml default: json description: - (deprecated) For local templates, allows specification of json or yaml format. Templates are now passed raw to CloudFormation regardless of format. This parameter is ignored since Ansible 2.3. required: false version_added: '2.0' version_added_collection: ansible.builtin create_changeset: default: false description: - 'If stack already exists create a changeset instead of directly applying changes. See the AWS Change Sets docs U(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html). WARNING: if the stack does not exist, it will be created without changeset. If the state is absent, the stack will be deleted immediately with no changeset.' required: false version_added: '2.4' version_added_collection: ansible.builtin disable_rollback: choices: - 'true' - 'false' default: 'false' description: - If a stacks fails to form, rollback will remove the stack required: false notification_arns: default: null description: - The Simple Notification Service (SNS) topic ARNs to publish stack related events. required: false version_added: '2.0' version_added_collection: ansible.builtin template_parameters: default: {} description: - a list of hashes of all the template variables for the stack required: false debug_botocore_endpoint_logs: default: 'no' description: - Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used. type: bool
events: description: Most recent events in Cloudformation's event log. This may be from a previous run in some cases. returned: always sample: - StackEvent AWS::CloudFormation::Stack stackname UPDATE_COMPLETE - StackEvent AWS::CloudFormation::Stack stackname UPDATE_COMPLETE_CLEANUP_IN_PROGRESS type: list log: description: Debugging logs. Useful when modifying or finding an error. returned: always sample: - updating stack type: list stack_outputs: description: A key:value dictionary of all the stack outputs currently defined. If there are no stack outputs, it is an empty dictionary. returned: state == present sample: MySg: AnsibleModuleTestYAML-CFTestSg-C8UVS567B6NS type: dict stack_resources: description: AWS stack resources and their status. List of dictionaries, one dict per resource. returned: state == present sample: - last_updated_time: '2016-10-11T19:40:14.979000+00:00' logical_resource_id: CFTestSg physical_resource_id: cloudformation2-CFTestSg-16UQ4CYQ57O9F resource_type: AWS::EC2::SecurityGroup status: UPDATE_COMPLETE status_reason: null type: list