Skip to content
Snippets Groups Projects
Select Git revision
  • master
1 result

Vagrantfile

Blame
  • Vagrantfile 13.46 KiB
    # https://github.com/rubocop/ruby-style-guide
    gems_installed=false
    required_gems = ["recursive-open-struct"]
    required_gems.each do |gem|
      unless Vagrant.has_plugin? gem 
    	print "Gem '" + gem + "' is required to process the vagrantfile, do you want to install it [Y/N]? "
    	input = STDIN.gets.chomp
    	abort "Gem requirement unmeet exiting" unless input.to_s.downcase  == "y"
    	abort "Gem requirement unmeet exiting" unless system "vagrant plugin install #{gem}"
    	gems_installed = true
      end
    end
    if gems_installed 
    	exec "vagrant #{ARGV.join(' ')}"
    end
    
    require 'recursive-open-struct'
    
    # Function to check whether VM was already provisioned
    def provisioned?(vm_name:'default', provider:'virtualbox')
    	File.exist?(".vagrant/machines/#{vm_name}/#{provider}/action_provision")
    end
    
    # avoid tabs in yaml!!! YAML or Psych
    vms_hash = Psych.load <<-EOF
      group: "/srkt"
      relative_machinefolder: ../vm
      management:
        name: management
        gui: true
        memory: 1024
        cores: 1
        accelerate_3d: false
        hdd:
        hdd2: 5120
        ip: 192.168.56.10
        box: centos/8
      nodes:
        - name: kubernetes01
          gui: true
          memory: 2048
          cores: 2
          accelerate_3d: false
          hdd:
          hdd2: 5120
          ip: 192.168.56.11
          box: centos/8
        - name: kubernetes02
          gui: true
          memory: 2048
          cores: 2
          accelerate_3d: false
          hdd:
          hdd2: 5120
          ip: 192.168.56.12
          box: centos/8
        - name: kubernetes03
          gui: true
          memory: 2048
          cores: 2
          accelerate_3d: false
          hdd:
          hdd2: 5120
          ip: 192.168.56.13
          box: centos/8
    #    - name: kubernetes04
    #      gui: true
    #      memory: 2048
    #      cores: 2
    #      accelerate_3d: false