Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save john-auld/75ed8f9209dbbcaf0dee867b58fa19ba to your computer and use it in GitHub Desktop.
Save john-auld/75ed8f9209dbbcaf0dee867b58fa19ba to your computer and use it in GitHub Desktop.
Ansible playbook to dump a DNS Zone hosted by Digital Ocean to a BIND style zone file.
---
#
# Dump DNS Zone file from a zone hosted by Digital Ocean
#
- hosts: localhost
connection: local
gather_facts: false
vars:
oauth_token: "redacted-api-key-from-digital-ocean"
zone: "example.com"
tasks:
- name: Gather facts about domain with given name
digital_ocean_domain_facts:
oauth_token: "{{ oauth_token }}"
domain_name: "{{ zone }}"
register: resp_out
- name: debug stdout
set_fact:
zone_data: "{{ resp_out }}"
- name: Output zone file
local_action: copy content={{ zone_data.data[0].zone_file }} dest="{{ zone }}.zone.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment