Module: EasyConfig::Config
- Extended by:
- Config
- Included in:
- Config
- Defined in:
- lib/vagrant-easyconfig/config.rb,
lib/vagrant-easyconfig/config_template.rb
Constant Summary collapse
- @@config =
{}
- @@config_template =
"---\ndefault:\n vm:\n gui: false\n memory: 4096\n cpus: 4\n storage: 10GB\n # list of boxes that may be used for this project\n boxes:\n ubuntu1804: ubuntu/bionic64\n ubuntu: ubuntu/focal64\n # key for the box that is used for this project\n box: ubuntu\n hosts:\n # name of the host\n example-host:\n # if no ip is given it will be generated from net.ip\n ip:\n # groups used for ansible\n groups:\n # aliases are added to the /etc/hosts on the host and guest\n aliases:\n # override vm options per host\n # vm:\n # memory: 8192\n plugins:\n # automatically installs vbguest, hostmanager and disksize\n auto_install: true\n vbguest:\n # turn off auto_update of vbguest\n auto_update: true\n linked_clones: true\n net:\n # ip to auto generate IPs from\n # incrementing by 1 for every host\n ip: 192.168.100.100\n private_nic_type: 82540EM\n network_type: private_network\n ansible:\n # whether to use ansible_local or ansible provisioner\n local: true\n # whether to install ansible with guest OS or pip\n pip: false\n # where the ansible project is located\n project_path:\n # where the playbook is located inside the ansible project\n playbook:\n # when used passes the extra_vars to ansible\n extra_vars:\n # when used only tasks with these tags are run\n tags:\n # when used all tasks except for one with these tags are run\n skip_tags:\n # toggle verbose logging for ansible\n verbose: false\n # will be disable on unix systems\n windows:\n ssh:\n # specify ssh-key location\n key:\n# override for current host\n# by specifying the hostname of the current machine\n# all settings under this key are overriding the default section\n\#{`hostname`[0..-2].downcase}:\n# vm:\n# memory: 8192\n# hosts:\n# example-host:\n# vm:\n# memory: 16384\n".strip
Class Method Summary collapse
Class Method Details
.get(*args) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/vagrant-easyconfig/config.rb', line 45 def self.get(*args) if @@config == nil abort "Easyconfig:Config.get: load config first with [Config.load(path)]" end if args.length == 0 return Marshal.load(Marshal.dump(@@config)) end return Marshal.load(Marshal.dump(@@config.dig(*args))) end |
.load(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-easyconfig/config.rb', line 15 def self.load(path) config_path = File.(path, Dir.pwd) vagrantfile_path = File.('Vagrantfile', Dir.pwd) unless File.exist? vagrantfile_path config_path = File.(path, File.dirname(File.dirname(File.dirname(__FILE__)))) end unless File.exist? config_path File.write("#{config_path}.template", @@config_template) abort " Easyconfig:Config.load: Cannot load file [\#{config_path}]\n Easyconfig:Config.load: Create template [\#{config_path}.template]\n Easyconfig:Config.load: Copy the template to [\#{config_path}] and adapt\n EOL\n end\n\n self.merge_template config_path\n self.merge_default\n self.set_hostnames\n self.set_boxes\n self.auto_install_plugins\n self.initialize_ansible\n\n unless OS.windows?\n @@config.delete(\"windows\")\n end\n\n self.post_initialize\n return nil\nend\n" |
.print ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/vagrant-easyconfig/config.rb', line 55 def self.print if @@config == nil abort "Easyconfig:Config.print: load config first with [Config.load(path)]" end puts @@config.to_yaml puts "---\n\n" return nil end |