Automizing creation of multiple DNS records

Hey community!

Does anyone use Ansible to automize creation of DNS records?

In our case, we started to use Ansible’s Cloudflare community module. The problem is that we have over a thousand DNS records and the playbook takes awhile to check/update all of them.

I wonder if there is any other solution to update multiple DNS records for a system already in production?

1 Like

You could update the DNS records with the API?
Update Record:
https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record
Create Record:
https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record

The rate limit for the API seems to be 1200 requests every 5 mintues according to How many API calls can I make? – Cloudflare Help Center.

Hey @bailey.stringer,
Thank you for your reply.

That’s actually how Ansible’s Cloudflare community module is working internally – using these API methods. The issue is that we have over a thousand DNS records, so checking existing records and creating new ones exceed the limit. To mitigate a problem with the limit, Ansible adds a delay to each request. That’s why update takes quite a long time.

Cloudflare allows to import/export DNS records in a BIND format, but it’s not clear how to apply just changes without updating existing records. It seems that using export/import API may lead to consistency issues.