Git Product home page Git Product logo

cloudflare-dns-update-google-spf's Introduction

This is an Ansible playbook to maintain TXT records on CloudFlare for SPF on G-Suite. You have to supply it with your CloudFlare API token as well as the CloudFlare zone (example.com) to act on. You then give the records you want to add by putting them in list format under the 'spf' variable. Each list element must have 'record', which is the name of the entry to add (record of 'test' would make the TXT entry for test.zone). Each list item must then have a value(s) for 'ipv4' and/or 'ipv6' which can be either a DNS entry to resolve to the A (IPv4) or AAAA (IPv6) record, or an IP address.


Why?

Servers that I run can send internal emails to myself if I have their IP added to the SPF record of the domain they're trying to send as. This allows me to have a script to automatically update the IP's of those TXT records if they have changed since my servers run a dynamic DNS that would update their A/AAAA record when they notice a Public IP change.

Usage

  • Fill 'vars.yml' in this style:
  # Generate the API Token at this address
  cf_api_token: 'https://dash.cloudflare.com/profile/api-tokens'
  # CloudFlare zone to create the records at
  cf_zone: 'example.com'
  # List of the SPF records and the IP's/Domain's to resolve and add to the record.
  # (Can contain IPv4 and/or IPv6 entries)
  spf:
    # Create the SPF for a.example.com with the IPv4 address of 'test.com' and '192.168.0.1'
    - record: 'a'
      ipv4:
        - 'test.com'
        - '192.168.0.1'
    # Create the SPF for foo.bar.example.com with the IPv4 address of 'test.com' and '192.168.0.1'
    # and the IPv6 address of AAAA.to.resolve.com as well as 'aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa'
    - record: 'foo.bar'
      ipv4:
        - 'test.org'
        - '192.168.0.1'
      ipv6:
        - 'AAAA.to.resolve'
        - 'bbbb:bbbb:bbbb:bbbb:bbbb:bbbb:bbbb:bbbb'
  • Run the playbook
ansible-playbook cloudflare-dns-update-spf.yml

This would create the following TXT records:
a.example.com:
v=spf1 ipv4:1.1.1.1 ipv4:192.168.0.1 include:_spf.google.com ~all (assuming test.com resolves to 1.1.1.1)
foo.bar.example.com:
v=spf1 ipv4:8.8.8.8 ipv4:192.168.0.1 ipv6:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa ipv6:bbbb:bbbb:bbbb:bbbb:bbbb:bbbb:bbbb:bbbb include:_spf.google.com ~all (assuming test.org resolves to 8.8.8.8 and AAAA.to.resolve resolves to 'aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.