mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-20 13:50:45 +00:00
82 lines
3.2 KiB
Plaintext
82 lines
3.2 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 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'][0] %>"
|
|
<% when 'network' -%>
|
|
<% if selected_module.attributes['range'][0].nil? || selected_module.attributes['range'][0] == "dhcp" -%>
|
|
<%= system.name %>.vm.network :<%= selected_module.attributes['type'][0] %>, type: "dhcp"
|
|
<% else -%>
|
|
<%= system.name %>.vm.network :<%= selected_module.attributes['type'][0] %>, ip: "<%= selected_module.attributes['range'][0] %>"
|
|
<% end -%>
|
|
<% when 'vulnerability', 'service', 'utility', 'encoder', 'generator' -%>
|
|
<% 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 -%>
|
|
|
|
#TODO: fixme!
|
|
# # clean up script which clears history from the VMs and clobs files together
|
|
# <%= system.name %>.vm.provision "puppet" do |cleanup|
|
|
# cleanup.module_path = "<%="#{ROOT_DIR}/mount/puppet/module"%>"
|
|
# cleanup.environment_path = "<%="#{ENVIRONMENTS_DIR}"%>"
|
|
# cleanup.environment = "production"
|
|
# cleanup.manifests_path = "<%="#{ROOT_DIR}/mount/puppet/manifest"%>"
|
|
# cleanup.manifest_file = "cleanup.pp"
|
|
# end
|
|
<%= system.name %>.vm.provision :shell, :inline => "history -c && history -w"
|
|
# <%= system.name %>.vm.provision :shell, :inline => "umount /mount/"
|
|
end
|
|
<% end %>
|
|
end
|