ec2_eip - associate an EC2 elastic IP with an instance.

Author:Lorin Hochstein <lorin@nimbisservices.com>

Synopsis

New in version 1.4.

This module associates AWS EC2 elastic IP addresses with instances

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.
      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
        in_vpc no
          allocate an EIP inside a VPC or not (added in Ansible 1.4)
          instance_id no
            The EC2 instance id
            profile no
              uses a boto profile. Only works with boto >= 2.24.0 (added in Ansible 1.6)
              public_ip no
                The elastic IP address to associate with the instance.If absent, allocate a new address
                region no
                  the EC2 region to use
                  reuse_existing_ip_allowed no
                    Reuse an EIP that is not associated to an instance (when available), instead of allocating a new one. (added in Ansible 1.6)
                    security_token no
                      security token to authenticate against AWS (added in Ansible 1.6)
                      state no present
                      • present
                      • absent
                      If present, associate the IP with the instance.If absent, disassociate the IP with the instance.
                      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_timeout no 300
                        how long to wait in seconds for newly provisioned EIPs to become available (added in Ansible 1.7)

                        Note

                        Requires boto

                        Examples


                        - name: associate an elastic IP with an instance
                          ec2_eip: instance_id=i-1212f003 ip=93.184.216.119
                        
                        - name: disassociate an elastic IP from an instance
                          ec2_eip: instance_id=i-1212f003 ip=93.184.216.119 state=absent
                        
                        - name: allocate a new elastic IP and associate it with an instance
                          ec2_eip: instance_id=i-1212f003
                        
                        - name: allocate a new elastic IP without associating it to anything
                          ec2_eip:
                          register: eip
                        - name: output the IP
                          debug: msg="Allocated IP is {{ eip.public_ip }}"
                        
                        - name: provision new instances with ec2
                          ec2: keypair=mykey instance_type=c1.medium image=emi-40603AD1 wait=yes group=webserver count=3
                          register: ec2
                        - name: associate new elastic IPs with each of the instances
                          ec2_eip: "instance_id={{ item }}"
                          with_items: ec2.instance_ids
                        
                        - name: allocate a new elastic IP inside a VPC in us-west-2
                          ec2_eip: region=us-west-2 in_vpc=yes
                          register: eip
                        - name: output the IP
                          debug: msg="Allocated IP inside a VPC is {{ eip.public_ip }}"

                        Note

                        This module will return public_ip on success, which will contain the public IP address associated with the instance.

                        Note

                        There may be a delay between the time the Elastic IP is assigned and when the cloud instance is reachable via the new address. Use wait_for and pause to delay further playbook execution until the instance is reachable, if necessary.

                        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