chef-boneyard/dynect

Support multiple records of same type per FQDN

Opened this issue · 1 comments

Attempting to setup MX routing for Google is not possible, currently.

# MX records (Google Apps)
dynect_rr 'mx1' do
  record_type 'MX'
  rdata({'exchange' => 'ASPMX.L.GOOGLE.COM.', 'preference' => '1'})
  fqdn node['dynect']['zone']
  customer node['dynect']['customer']
  username node['dynect']['username']
  password node['dynect']['password']
  zone node['dynect']['zone']
  action :create
end

dynect_rr 'mx2' do
  record_type 'MX'
  rdata({'exchange' => 'ALT1.ASPMX.L.GOOGLE.COM.', 'preference' => '5'})
  fqdn node['dynect']['zone']
  customer node['dynect']['customer']
  username node['dynect']['username']
  password node['dynect']['password']
  zone node['dynect']['zone']
  action :create
end

Most record types can have more than one RR for a given address. This is especially common with NS, MX, TXT and even A records. Setting up Google MX uses 5 records, for example.

Running the above after manually creating the records yields:

  * dynect_rr[mx1] action create

    ================================================================================
    Error executing action `create` on resource 'dynect_rr[mx1]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `fqdn' for #<Array:0x0000000762f870>

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/dynect/providers/rr.rb:36:in `load_current_resource'

Obviously, the object is an array of objects, versus just a single object.