Skip to content
/ dns Public

DNS as code.

Notifications You must be signed in to change notification settings

mbtamuli/dns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

dns

Test on PR

Deploy on push

Mriyam's DNS entries using GitHub Actions. Inspired from this article

Making changes

Modify the YAML file for the zone you'd like to update. The top-level key is the subdomain value, and its value is a Hash/Dictionary of values.

For more details, check here - Records Documentation

Note:

  1. Auto TTL on Cloudflare equals 300 seconds
  2. For proxied records, Cloudflare manages TTL, so the value doesn't apply

Running locally

From the root of the repo, run

docker run --rm -it \
    --env CLOUDFLARE_EMAIL="$CLOUDFLARE_EMAIL" \
    --env CLOUDFLARE_TOKEN="$CLOUDFLARE_TOKEN" \
    --volume $PWD/config:/config \
    parkr/octodns:v0.9.5 \
    octodns-sync --config-file ./config/production.yaml

If you want to actually make the change, just add --doit at the end.

docker run --rm -it \
    --env CLOUDFLARE_EMAIL="$CLOUDFLARE_EMAIL" \
    --env CLOUDFLARE_TOKEN="$CLOUDFLARE_TOKEN" \
    --volume $PWD/config:/config \
    parkr/octodns:v0.9.5 \
    octodns-sync --config-file ./config/production.yaml --doit

Initializing another domain

Assuming the domain is on cloudflare, you need to run this from the root of the repo.

docker run --rm -it \
    --env CLOUDFLARE_EMAIL="$CLOUDFLARE_EMAIL" \
    --env CLOUDFLARE_TOKEN="$CLOUDFLARE_TOKEN" \
    -v $(pwd):/opt/dns \
    parkr/octodns:v0.9.5 \
    octodns-dump \
    --config-file /opt/dns/config/production.yaml \
    --output-dir /opt/dns/config \
    "example.com." \
    cloudflare

Example records

  1. A record with minimum TTL.
    mail:
      ttl: 120
      type: A
      value: 1.1.1.1
  2. A record with TTL equivalent to auto TTL.
    blog:
      ttl: 300
      type: A
      value: 1.1.1.1
  3. CNAME record with Cloudflare Proxy disabled
    www:
      octodns:
        cloudflare:
          proxied: false
      ttl: 3600
      type: CNAME
      value: mbtest.ga.

GitHub Workflow

  1. Create a new branch and check it out.
  2. Modify a record and commit the changes.
  3. Push the changes and submit a PR.
  4. GitHub Actions runs octodns-sync to generate plan.
  5. Verify the records in the output of the dry run and merge the PR.
  6. GitHub Actions runs octodns-sync --doit to apply the plan.