cookbook 'cloudflare', '= 0.1.4', :supermarket
cloudflare (7) Versions 0.1.4 Follow3
Registers your server with Cloudflare's DNS service
cookbook 'cloudflare', '= 0.1.4'
knife supermarket install cloudflare
knife supermarket download cloudflare
This Chef! cookbook defines one LWRP that you can easily use in your own cookbook to create and delete Cloudflare DNS records.
It is built on top of B4k3r's Ruby wrapper for the Cloudflare API. (https://github.com/B4k3r/cloudflare)
Requires Chef-client version 11.x or later.
To be able to use the
clouflare_dns_record resource, you must define two nodes attributes:
I strongly recommend storing your Cloudflare credentials in an encrypted data bag, and then decrypting them in your own cookbook.
There also are a number of optional node attributes:
['cloudflare']['check_credentials']: whether to check your Cloudflare credentials before attempting any API call (defaults to
['cloudflare']['check_zone']: whether to check if the specified DNS zone(s) exist(s) on your Cloudflare account before trying to add or delete records (defaults to
['cloudflare']['check_with_DNS']: whether to try checking your records' existence against a DNS server rather than querying the Cloudflare API (will still query the Cloudflare API if the DNS server does not return what's expected - defaults to
['cloudflare']['DNS_server']: if you use the
check_with_DNSoption, that is the DNS server that will be queried (defaults to
ns.cloudflare.com, which is Cloudflare's main public DNS server)
Those attributes come in especially handy if you have a number of servers and get throttled by Cloudflare's API limits.
To use the
clouflare_dns_record resource in your own cookbook, simply tell Chef! that your cookbook depends on this one, by adding
depends 'cloudflare' in your
This resource defines the following attributes (they're all
Strings unless otherwise specified):
name(required): the name of the Chef! resource. It is also the name of the DNS record, unless the
record_nameattribute is set
record_name(optional): as said above, you can set that attribute to override the name of the DNS record (useful for registering several records with the same name - e.g. in different zones - during the same Chef! run)
zone(required): the zone of the DNS record
content(optional - defaults to
node.ipaddress): the content of the DNS record
'CNAME'- defaults to
'A'): the type of the DNS record. Please let me know if you'd like other record types supported
ttl(must be a
Fixnum- defaults to
1, which, according to Cloudflare doc, means 'automatic'): the ttl of the DNS record
For instance, the following code in your cookbook's recipe would create an
A DNS record
server_name.example.com pointing to
220.127.116.11 with an automatic TTL:
cloudflare_dns_record 'server_name' do zone 'example.com' content '18.104.22.168' end
clouflare_dns_record resource defines two different actions:
:delete (pretty self-explanatory);
:create is the default one.
cloudflare_dns_record 'resource_name' do zone 'example.com' record_name 'server_name' action :delete end
would delete the
server_name.example.com record from your Cloudflare account.
Contributing & Feedback
As always, I appreciate bug reports, suggestions, pull requests, feedback... Feel free to reach me at email@example.com
0.1.4 (Apr 23, 2014)
- Fixed a bug when there were too many records to be loaded in one call from CloudFlare
- Made it more compliant with ill-formatted record names
0.1.3 (Mar 21, 2014)
- Upgraded the Cloudflare gem to the newest version 2.0.1
0.1.2 (Nov 14, 2013)
- Changed default DNS server from Google's to Cloudflare's to avoid new records from not resolving for a long time on Google's server
0.1.1 (Nov 6, 2013)
- Some small bug fixes
- Reduced the number of calls to the Cloudflare API with the vanilla options
- Added a number of options to reduce the number of calls to the Cloudflare API further, most notably made it possible to query a DNS server to check records' existence
0.1.0 (Oct 3, 2013)
- Initial release
This cookbook has no specified dependencies.
There are no cookbooks that are contingent upon this one.