Sha256: 841a35c99c2c8dadcace6f77a42ac813cbc3eeaeb4b6361803ab7c8f035cd454

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

#
# Cookbook Name:: wombat
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.

all_hosts = node['demo']['hosts'].to_h
build_ip = 50
infra_ip = 100
wkstn_ip = 200
if node['platform'] == 'windows'
  tmp_dir = "C:\\Windows\\Temp"
else
  tmp_dir = "/tmp/"
end

infranodes_file = File.join(tmp_dir, "infranodes-info.json")

if File.exists?(infranodes_file)
  infranodes = JSON(File.read(infranodes_file))
else
  infranodes = {}
end

1.upto(node['demo']['build-nodes'].to_i) do |i|
  build_node_name = "build-node-#{i}"
  next if all_hosts.key?(build_node_name)
  build_ip += 1
  all_hosts[build_node_name] = "172.31.54.#{build_ip}"
end

1.upto(node['demo']['workstations'].to_i) do |i|
  wkstn_name = "workstation-#{i}"
  next if all_hosts.key?(wkstn_name)
  wkstn_ip += 1
  all_hosts[wkstn_name] = "172.31.54.#{wkstn_ip}"
end

infranodes.sort.each do |name, _info|
  next if all_hosts.key?(name)
  infra_ip += 1
  all_hosts[name] = "172.31.54.#{infra_ip}"
end

all_hosts.each do |hostname, ipaddress|
  hostsfile_entry ipaddress do
    hostname  "#{node['demo']['domain_prefix']}#{hostname}.#{node['demo']['domain']}"
    aliases   [hostname]
    action    :create
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wombat-cli-0.6.1 generator_files/cookbooks/wombat/recipes/etc-hosts.rb
wombat-cli-0.6.0 generator_files/cookbooks/wombat/recipes/etc-hosts.rb
wombat-cli-0.5.0 generator_files/cookbooks/wombat/recipes/etc-hosts.rb
wombat-cli-0.4.3 generator_files/cookbooks/wombat/recipes/etc-hosts.rb
wombat-cli-0.4.2 generator_files/cookbooks/wombat/recipes/etc-hosts.rb