我在厨师服务器中运行配方,获取ec2节点主机名和公共DNS,并创建cname指向hostname.mydomain.com以便于访问。 我正在将所有内容都移到VPC中,现在私有网络中没有更多的公共DNS感知,并且在A类中使用私有IP地址。 我需要让厨师创建A记录,而不是指向私有IP地址的cname。
这是食谱:
aws=Hash.new aws['aws_access_key_id'] = node[:base][:aws [:access_key_id] aws['aws_secret_access_key'] = node[:base][:aws][:secret_access_key] if node[:base][:aws][:route53][:update_cname_records] == true cnames = [] cnames << "#{node.name}" unless node[:base][:aws][:route53][:additional_cnames].nil? node[:base][:aws][:route53][:additional_cnames].each do |n|
cnames << n
end end
cnames.each do |cname|
cname_fqdn = "#{cname}.#{node[:base][:aws][:route53][:management_zone_name]}"
log ("Updating Route53 CNAME record for #{cname_fqdn}") { level :warn }
aws_route53_record "Create Route53 CNAME record for #{cname_fqdn}" do
name cname_fqdn
value node[:cloud][:public_hostname]
type "CNAME"
ttl node[:base][:aws][:route53][:ttl]
zone_id node[:base][:aws][:route53][:management_zone_id]
aws_access_key aws['aws_access_key_id']
aws_secret_access_key aws['aws_secret_access_key']
action :create
end end
else log ("NOT updating Route53 CNAME records because node[:base][:aws][:route53][:update_cname_records] = #{node[:base][:aws][:route53][:update_cname_records]}") { level :warn } end