Module: EasyConfig::Plugins

Defined in:
lib/vagrant-easyconfig/plugins.rb

Class Method Summary collapse

Class Method Details

.add_aliases(config) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vagrant-easyconfig/plugins.rb', line 58

def self.add_aliases(config)
  if Vagrant.has_plugin?('vagrant-hostmanager')
    if Config.get("hosts", config.vm.hostname).key?("aliases")
      aliases = Config.get("hosts", config.vm.hostname,"aliases")
      if aliases.kind_of?(Array) && aliases.length > 0
        config.hostmanager.aliases = aliases
      end
    end
  end
  return nil
end

.configure(config) ⇒ Object



6
7
8
9
10
# File 'lib/vagrant-easyconfig/plugins.rb', line 6

def self.configure(config)
  self.configure_hostmanager(config)
  self.configure_vbguest(config)
  return nil
end

.configure_disksize(config) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vagrant-easyconfig/plugins.rb', line 46

def self.configure_disksize(config)
  if Vagrant.has_plugin?("vagrant-disksize")
    config.disksize.size = Config.get("hosts", config.vm.hostname, "vm","storage")
  else
    puts <<~EOL
    Easyconfig:Plugins.configure_disksize: no disksize plugin installed, thus storage is not set correctly to #{ vm.fetch("storage") }
    Easyconfig:Plugins.configure_disksize: vagrant plugin install vagrant-disksize
    EOL
  end
  return nil
end

.configure_hostmanager(config) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-easyconfig/plugins.rb', line 12

def self.configure_hostmanager(config)
  if Vagrant.has_plugin?('vagrant-hostmanager')
    config.hostmanager.enabled            = true
    config.hostmanager.manage_host        = true
    config.hostmanager.manage_guest       = true
    config.hostmanager.ignore_private_ip  = false
    config.hostmanager.include_offline    = true
  else
    puts <<~EOL
    Easyconfig:Plugins.configure_hostmanager: no hosts plugin installed, thus no aliases are added to the /etc/hosts file
    Easyconfig:Plugins.configure_hostmanager: plugin examples: vagrant-hostmanager
    EOL
  end
  return nil
end

.configure_vbguest(config) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vagrant-easyconfig/plugins.rb', line 28

def self.configure_vbguest(config)
  if Vagrant.has_plugin?("vagrant-vbguest")
    auto_update = Config.get("plugins","vbguest","auto_update")
    config.vbguest.auto_update = auto_update != nil ? auto_update : true
    if OS.unix?
      config.vm.synced_folder ".", "/vagrant", disabled: false
    else
      config.vm.synced_folder ".", "/vagrant", disabled: false, mount_options: ["dmode=0755,fmode=0644"]
    end
  else
    puts <<~EOL
    Easyconfig:Plugins.configure_vbguest: no vagrant-vbguest plugin installed, thus no autoupdates and synced folders are working
    Easyconfig:Plugins.configure_vbguest: install with: vagrant plugin install vagrant-vbguest
    EOL
  end
  return nil
end