<commit_before>require 'resolv'
require 'chef/util/file_edit'

src_filename = ::File.basename(node['chef-server']['package_url'])
file_path = "#{Chef::Config['file_cache_path']}/#{src_filename}"

execute "wget -O #{file_path} #{node['chef-server']['package_url']}" do
  user 'root'
end

execute "dpkg -i #{file_path}" do
  user 'root'
end

ruby_block "ensure node can resolve API FQDN" do
  block do
    fe = Chef::Util::FileEdit.new("/etc/hosts")
    fe.insert_line_if_no_match(/#{node['chef-server']['api_fqdn']}/,
                               "127.0.0.1 #{node['chef-server']['api_fqdn']}")
    fe.write_file
  end
  not_if { Resolv.getaddress(node['chef-server']['api_fqdn']) rescue false } # host resolves<commit_msg>vagrant friendly installation<commit_after>require 'resolv'
require 'chef/util/file_edit'

src_filename = ::File.basename(node['chef-server']['package_url'])

if Dir.exist? '/vagrant'
  file_path = "/vagrant/tmp/#{src_filename}"
else
  file_path = "#{Chef::Config['file_cache_path']}/#{src_filename}"
end

unless File.exist? file_path
  package "wget"

  execute "wget -O #{file_path} #{node['chef-server']['package_url']}" do
    user 'root'
  end
end

execute "dpkg -i #{file_path}" do
  user 'root'
end

ruby_block "ensure node can resolve API FQDN" do
  block do
    fe = Chef::Util::FileEdit.new("/etc/hosts")
    fe.insert_line_if_no_match(/#{node['chef-server']['api_fqdn']}/,
                               "127.0.0.1 #{node['chef-server']['api_fqdn']}")
    fe.write_file
  end
  not_if { Resolv.getaddress(node['chef-server']['api_fqdn']) rescue false } # host resolves
{'fraction_non_alphanumeric': 0.1771678103555833, 'fraction_numerical': 0.007485963817841547, 'mean_word_length': 4.32890365448505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3992737', 'n_tokens_mistral': 600, 'n_tokens_neox': 597, 'n_words': 110}