ec2_ami - create or destroy an image in ec2, return imageid

Author:Evan Duffield <eduffield@iacquire.com>

Synopsis

New in version 1.3.

Creates or deletes ec2 images. This module has a dependency on python-boto >= 2.5

Options

parameter required default choices comments
aws_access_key no
    AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used.
    aws_secret_key no
      AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used.
      delete_snapshot no
        Whether or not to deleted an AMI while deregistering it.
        description no
          An optional human-readable string describing the contents and purpose of the AMI.
          ec2_url no
            Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Must be specified if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used
            image_id no
              Image ID to be deregistered.
              instance_id no
                instance id of the image to create
                name no
                  The name of the new image to create
                  no_reboot no
                  • yes
                  • no
                  An optional flag indicating that the bundling process should not attempt to shutdown the instance before bundling. If this flag is True, the responsibility of maintaining file system integrity is left to the owner of the instance. The default choice is "no".
                  profile no
                    uses a boto profile. Only works with boto >= 2.24.0 (added in Ansible 1.6)
                    region no
                      The AWS region to use. Must be specified if ec2_url is not used. If not specified then the value of the EC2_REGION environment variable, if any, is used.
                      security_token no
                        security token to authenticate against AWS (added in Ansible 1.6)
                        state no present
                          create or deregister/delete image
                          validate_certs no yes
                          • yes
                          • no
                          When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0. (added in Ansible 1.5)
                          wait no no
                          • yes
                          • no
                          wait for the AMI to be in state 'available' before returning.
                          wait_timeout no 300
                            how long before wait gives up, in seconds

                            Note

                            Requires boto

                            Examples


                            # Basic AMI Creation
                            - local_action:
                                module: ec2_ami
                                aws_access_key: xxxxxxxxxxxxxxxxxxxxxxx
                                aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                instance_id: i-xxxxxx
                                wait: yes
                                name: newtest
                              register: instance
                            
                            # Basic AMI Creation, without waiting
                            - local_action:
                                module: ec2_ami
                                aws_access_key: xxxxxxxxxxxxxxxxxxxxxxx
                                aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                region: xxxxxx
                                instance_id: i-xxxxxx
                                wait: no
                                name: newtest
                              register: instance
                            
                            # Deregister/Delete AMI
                            - local_action:
                                module: ec2_ami
                                aws_access_key: xxxxxxxxxxxxxxxxxxxxxxx
                                aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                region: xxxxxx
                                image_id: ${instance.image_id}
                                delete_snapshot: True
                                state: absent
                            
                            # Deregister AMI
                            - local_action:
                                module: ec2_ami
                                aws_access_key: xxxxxxxxxxxxxxxxxxxxxxx
                                aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                region: xxxxxx
                                image_id: ${instance.image_id}
                                delete_snapshot: False
                                state: absent

                            Note

                            The following environment variables can be used AWS_ACCESS_KEY or EC2_ACCESS_KEY or AWS_ACCESS_KEY_ID, AWS_SECRET_KEY or EC2_SECRET_KEY or AWS_SECRET_ACCESS_KEY, AWS_REGION or EC2_REGION, AWS_SECURITY_TOKEN

                            Note

                            Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See http://boto.readthedocs.org/en/latest/boto_config_tut.html

                            Note

                            AWS_REGION or EC2_REGION can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file