Files
SecGen/lib/templates/Vagrantfile.erb
2017-01-17 16:11:50 +00:00

74 lines
2.7 KiB
Plaintext

# -*- mode: ruby -*-
# vi: set ft=ruby :
# This file was generated by SecGen
# <%= @time %>
# Based on <%= @scenario %>
<% require 'json' %>
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% @systems.each do |system| %>
config.vm.define "<%= system.name %>" do |<%= system.name %>|
config.vm.provider :virtualbox do |vb|
<%= if (@options.has_key? :gui_output)
" vb.gui = true"
else
" vb.gui = false
vb.customize ['modifyvm', :id, '--pae', 'on']
vb.customize ['modifyvm', :id, '--hwvirtex', 'off']
vb.customize ['modifyvm', :id, '--vtxvpid', 'off']"
end -%>
<%= if (@options.has_key? :memory_per_vm)
" vb.memory = #{@options[:memory_per_vm]}"
elsif (@options.has_key? :total_memory)
" vb.memory = #{@options[:total_memory]}/#{@systems.length}"
end -%>
<%= if (@options.has_key? :max_cpu_cores)
" vb.cpus = #{@options[:max_cpu_cores]}"
end -%>
<%= if (@options.has_key? :max_cpu_usage)
" vb.customize ['modifyvm', :id, '--cpuexecutioncap', '#{@options[:max_cpu_usage]}']"
end %>
end
# SecGen datastore
# <%= JSON.generate($datastore) %>
# SecGen modules
<% system.module_selections.each do |selected_module| -%>
<%= selected_module.to_s_comment -%>
<% case selected_module.module_type
when 'base' -%>
<%= system.name %>.vm.box = "<%= selected_module.module_path_name %>"
<%= system.name %>.vm.box_url = "<%= selected_module.attributes['url'].first %>"
<% when 'network' -%>
<% if selected_module.attributes['range'].first.nil? || selected_module.attributes['range'].first == "dhcp" -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp"
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module.attributes['range'].first)%>"
<% end -%>
<% when 'vulnerability', 'service', 'utility', 'build' -%>
<% module_name = selected_module.module_path_name -%>
<%= system.name %>.vm.provision "puppet" do | <%=module_name%> |
<% # if there are facter variables to define
if selected_module.received_inputs != {} -%>
<%=module_name%>.facter = {
"json_inputs" => '<%=JSON.generate(selected_module.received_inputs)%>'
}
<% end -%>
<%=module_name%>.module_path = "<%="puppet/#{system.name}/modules"%>"
<%=module_name%>.environment_path = "<%="#{ENVIRONMENTS_DIR}"%>"
<%=module_name%>.environment = "production"
<%=module_name%>.manifests_path = "<%="#{ROOT_DIR}/#{selected_module.module_path}/"%>"
<%=module_name%>.manifest_file = "<%="#{selected_module.module_path_end}.pp"%>"
end
<% end -%>
<% end -%>
end
<% end %>
end