diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-28 22:33:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 22:33:12 -0700 |
commit | 7e5e5820ad5865c91f962b2c2fbf8fc0f40e0867 (patch) | |
tree | 8f90830d84bf3828883b5603eda6ace58c1402c9 | |
parent | ff4656d9ae70d2e8810ec0a45f322b394c31083d (diff) | |
parent | e042718fe4a1a64026a15977bf4ac43f3bbccbcc (diff) | |
download | chef-7e5e5820ad5865c91f962b2c2fbf8fc0f40e0867.tar.gz |
Merge pull request #7087 from chef/validate_hostname
Add basic hostname validation on Windows
-rw-r--r-- | lib/chef/resource/hostname.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index f785d1b620..497176f45d 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -66,12 +66,12 @@ class Chef action :set do description "Sets the node's hostname" - ohai "reload hostname" do - plugin "hostname" - action :nothing - end - if node["platform_family"] != "windows" + ohai "reload hostname" do + plugin "hostname" + action :nothing + end + # set the hostname via /bin/hostname declare_resource(:execute, "set hostname to #{new_resource.hostname}") do command "/bin/hostname #{new_resource.hostname}" @@ -203,8 +203,9 @@ class Chef end else # windows + raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/./) - # suppress EC2 config service from setting our hostname + # suppress EC2 config service from setting our hostname if ::File.exist?('C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml') xml_contents = updated_ec2_config_xml if xml_contents.empty? |