diff options
author | Tim Smith <tsmith@chef.io> | 2021-04-04 23:43:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 23:43:11 -0700 |
commit | 2193fc2725b4d7c210e8f78f20cfe14b3dccb4f2 (patch) | |
tree | fbe051726164bafd6334af80bdf9467fd4fdab58 | |
parent | f6ffe68dbca1048e9c804d2bbcbb5e09475a8e1a (diff) | |
parent | 74f78cf99c512654d60be25b01247f631cfe66b9 (diff) | |
download | chef-2193fc2725b4d7c210e8f78f20cfe14b3dccb4f2.tar.gz |
Merge pull request #11273 from chef/smriti/10694_allow_fqdn_hostname_resource
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/hostname.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index 746ef34a5b..8a9d3bea13 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -50,6 +50,10 @@ class Chef description: "An optional property to set the hostname if it differs from the resource block's name.", name_property: true + property :fqdn, String, + description: "An optional property to set the fqdn if it differs from the resource block's hostname.", + introduced: "17.0" + property :ipaddress, String, description: "The IP address to use when configuring the hosts file.", default: lazy { node["ipaddress"] }, default_description: "The node's IP address as determined by Ohai." @@ -115,7 +119,9 @@ class Chef # make sure node['fqdn'] resolves via /etc/hosts unless new_resource.ipaddress.nil? - newline = "#{new_resource.ipaddress} #{new_resource.hostname}" + newline = "#{new_resource.ipaddress}" + newline << " #{new_resource.fqdn}" unless new_resource.fqdn.to_s.empty? + newline << " #{new_resource.hostname}" newline << " #{new_resource.aliases.join(" ")}" if new_resource.aliases && !new_resource.aliases.empty? newline << " #{new_resource.hostname[/[^\.]*/]}" r = append_replacing_matching_lines("/etc/hosts", /^#{new_resource.ipaddress}\s+|\s+#{new_resource.hostname}\s+/, newline) |