Documentation

route53 - add or delete entries in Amazons Route53 DNS service

New in version 1.3.

Synopsis

Creates and deletes DNS records in Amazons Route53 service

Requirements (on host that executes module)

  • python >= 2.6
  • boto

Options

parameter required default choices comments
alias
(added in 1.9)
no
  • True
  • False
Indicates if this is an alias record.
alias_evaluate_target_health
(added in 2.1)
no
    Whether or not to evaluate an alias target health. Useful for aliases to Elastic Load Balancers.
    alias_hosted_zone_id
    (added in 1.9)
    no
      The hosted zone identifier.
      aws_access_key
      no
        AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.

        aliases: ec2_access_key, access_key
        aws_secret_key
        no
          AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.

          aliases: ec2_secret_key, secret_key
          command
          yes
          • get
          • create
          • delete
          Specifies the action to take.
          ec2_url
          no
            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.
            failover
            (added in 2.0)
            no
              Failover resource record sets only. Whether this is the primary or secondary resource record set. Allowed values are PRIMARY and SECONDARY
              health_check
              (added in 2.0)
              no
                Health check to associate with this record
                hosted_zone_id
                (added in 2.0)
                no
                  The Hosted Zone ID of the DNS zone to modify
                  identifier
                  (added in 2.0)
                  no
                    Have to be specified for Weighted, latency-based and failover resource record sets only. An identifier that differentiates among multiple resource record sets that have the same combination of DNS name and type.
                    overwrite
                    no
                      Whether an existing record should be overwritten on create if values do not match
                      private_zone
                      (added in 1.9)
                      no
                        If set to true, the private zone matching the requested name within the domain will be used if there are both public and private zones. The default is to use the public zone.
                        profile
                        (added in 1.6)
                        no
                          uses a boto profile. Only works with boto >= 2.24.0
                          record
                          yes
                            The full DNS record to create or delete
                            region
                            (added in 2.0)
                            no
                              Latency-based resource record sets only Among resource record sets that have the same combination of DNS name and type, a value that determines which region this should be associated with for the latency-based routing
                              retry_interval
                              no 500
                                In the case that route53 is still servicing a prior request, this module will wait and try again after this many seconds. If you have many domain names, the default of 500 seconds may be too long.
                                security_token
                                (added in 1.6)
                                no
                                  AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.

                                  aliases: access_token
                                  ttl
                                  no 3600 (one hour)
                                    The TTL to give the new record
                                    type
                                    yes
                                    • A
                                    • CNAME
                                    • MX
                                    • AAAA
                                    • TXT
                                    • PTR
                                    • SRV
                                    • SPF
                                    • NS
                                    • SOA
                                    The type of DNS record to create
                                    validate_certs
                                    (added in 1.5)
                                    no yes
                                    • yes
                                    • no
                                    When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
                                    value
                                    no
                                      The new value when creating a DNS record. Multiple comma-spaced values are allowed for non-alias records. When deleting a record all values for the record must be specified or Route53 will not delete it.
                                      vpc_id
                                      (added in 2.0)
                                      no
                                        When used in conjunction with private_zone: true, this will only modify records in the private hosted zone attached to this VPC.
                                        This allows you to have multiple private hosted zones, all with the same name, attached to different VPCs.
                                        wait
                                        (added in 2.1)
                                        no
                                          Wait until the changes have been replicated to all Amazon Route 53 DNS servers.
                                          wait_timeout
                                          (added in 2.1)
                                          no 300
                                            How long to wait for the changes to be replicated, in seconds.
                                            weight
                                            (added in 2.0)
                                            no
                                              Weighted resource record sets only. Among resource record sets that have the same combination of DNS name and type, a value that determines what portion of traffic for the current resource record set is routed to the associated location.
                                              zone
                                              yes
                                                The DNS zone to modify

                                                Examples

                                                # Add new.foo.com as an A record with 3 IPs and wait until the changes have been replicated
                                                - route53:
                                                      command: create
                                                      zone: foo.com
                                                      record: new.foo.com
                                                      type: A
                                                      ttl: 7200
                                                      value: 1.1.1.1,2.2.2.2,3.3.3.3
                                                      wait: yes
                                                
                                                # Retrieve the details for new.foo.com
                                                - route53:
                                                      command: get
                                                      zone: foo.com
                                                      record: new.foo.com
                                                      type: A
                                                  register: rec
                                                
                                                # Delete new.foo.com A record using the results from the get command
                                                - route53:
                                                      command: delete
                                                      zone: foo.com
                                                      record: "{{ rec.set.record }}"
                                                      ttl: "{{ rec.set.ttl }}"
                                                      type: "{{ rec.set.type }}"
                                                      value: "{{ rec.set.value }}"
                                                
                                                # Add an AAAA record.  Note that because there are colons in the value
                                                # that the entire parameter list must be quoted:
                                                - route53:
                                                      command: "create"
                                                      zone: "foo.com"
                                                      record: "localhost.foo.com"
                                                      type: "AAAA"
                                                      ttl: "7200"
                                                      value: "::1"
                                                
                                                # Add a TXT record. Note that TXT and SPF records must be surrounded
                                                # by quotes when sent to Route 53:
                                                - route53:
                                                      command: "create"
                                                      zone: "foo.com"
                                                      record: "localhost.foo.com"
                                                      type: "TXT"
                                                      ttl: "7200"
                                                      value: '"bar"'
                                                
                                                # Add an alias record that points to an Amazon ELB:
                                                - route53:
                                                      command=create
                                                      zone=foo.com
                                                      record=elb.foo.com
                                                      type=A
                                                      value="{{ elb_dns_name }}"
                                                      alias=True
                                                      alias_hosted_zone_id="{{ elb_zone_id }}"
                                                
                                                # Add an alias record that points to an Amazon ELB and evaluates it health:
                                                - route53:
                                                      command=create
                                                      zone=foo.com
                                                      record=elb.foo.com
                                                      type=A
                                                      value="{{ elb_dns_name }}"
                                                      alias=True
                                                      alias_hosted_zone_id="{{ elb_zone_id }}"
                                                      alias_evaluate_target_health=True
                                                
                                                # Add an AAAA record with Hosted Zone ID.  Note that because there are colons in the value
                                                # that the entire parameter list must be quoted:
                                                - route53:
                                                      command: "create"
                                                      zone: "foo.com"
                                                      hosted_zone_id: "Z2AABBCCDDEEFF"
                                                      record: "localhost.foo.com"
                                                      type: "AAAA"
                                                      ttl: "7200"
                                                      value: "::1"
                                                
                                                # Add an AAAA record with Hosted Zone ID.  Note that because there are colons in the value
                                                # that the entire parameter list must be quoted:
                                                - route53:
                                                      command: "create"
                                                      zone: "foo.com"
                                                      hosted_zone_id: "Z2AABBCCDDEEFF"
                                                      record: "localhost.foo.com"
                                                      type: "AAAA"
                                                      ttl: "7200"
                                                      value: "::1"
                                                
                                                # Use a routing policy to distribute traffic:
                                                - route53:
                                                      command: "create"
                                                      zone: "foo.com"
                                                      record: "www.foo.com"
                                                      type: "CNAME"
                                                      value: "host1.foo.com"
                                                      ttl: 30
                                                      # Routing policy
                                                      identifier: "host1@www"
                                                      weight: 100
                                                      health_check: "d994b780-3150-49fd-9205-356abdd42e75"
                                                

                                                Notes

                                                Note

                                                If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence AWS_URL or EC2_URL, AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY or EC2_ACCESS_KEY, AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY or EC2_SECRET_KEY, AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN, AWS_REGION or EC2_REGION

                                                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

                                                This is a Core Module

                                                For more information on what this means please read Core Modules

                                                For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.