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".
                  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.
                    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