Open hoatle opened 7 years ago
let's use https://www.hashicorp.com/blog/hashicorp-vagrant-2-0/ for v0.6.0
this is the proposal for yaml instead of json:
# vars must be defined to be used
# format:
# key: ${ENV_VAR}
# key: ${ENV_VAR-:default}
# and "#{key}" can be used for settings values if available
variables:
node_name_prefix: ${NODE_NAME_PREFIX:-node}
node_hostname_prefix: ${NODE_HOSTNAME_PREFIX:-teracy-dev}
some_value: ${MY_VAR:-value}-affix
# vagrant related settings
vagrant:
require_version: ">= 2.1.0"
plugins:
- _id: "0"
name: vagrant-gatling-rsync
required: true
enabled: true
config_key: gatling
options:
latency: 0.5
time_format: "%H:%M:%S"
rsync_on_startup: true
- _id: "1"
name: vagrant-rsync-back
required: true
enabled: true
- _id: "2"
name: vagrant-hostmanager
required: true
enabled: true
config_key: hostmanger
options:
manage_host: true
manage_guest: true
# usually defined from workspace/dev-setup/
preload_extension_paths:
postload_extension_paths:
config_paths:
# teracy-dev related settings
teracy-dev:
require_version: ">= 0.6.0-a1-SNAPSHOT"
config_lookup_path: workspace/dev-setup/ # will look for workspace/dev-setup/config_default.yaml
# default settings for all nodes
default:
vm:
box: bento/ubuntu-16.04
box_version:
box_url:
providers:
- _id: "0"
name: virtualbox
gui: false
memory: 1024
description: "teracy-dev #{Time.now.getutc.to_i}"
provisioners:
- _id: "0"
type: chef_solo
verion: "13.1.31"
log_level: info # one of debug, info, warn, error, fatal. Default: info
cookbooks_path:
- vendor-cookbooks
- main-cookbooks
roles_path: roles
nodes_path: nodes
data_bags_path: data_bags
run_list:
- vim
- teracy-dev
json:
docker:
enabled: false
version: 1.8.0
- _id: "1"
type: ansible_local
# etc
# specific nodes, each node will override the default
nodes:
- name: "#{node_name_prefix}-1"
is_primary: true
vm:
hostname: "#{NODE_HOSTNAME_PREFIX}-1.local"
- name: "#{node_name_prefix}-2"
vm:
hostname: "#{NODE_HOSTNAME_PREFIX}-2.local"
the Vagrantfile could start with the following skeleton to work with the above yaml file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "rubygems"
require 'yaml'
# teracy-dev version
VERSION='0.6.0-a1-SNAPSHOT'
load File.dirname(__FILE__) + '/lib/utility.rb'
$logger = get_logger()
# learn from https://github.com/hashicorp/vagrant/blob/ee5656da37c75e896201d389c79da199114603c2/lib/vagrant.rb#L216
def require_version(*requirements)
$logger.info("teracy-dev version: #{VERSION}")
req = Gem::Requirement.new(*requirements)
if req.satisfied_by?(Gem::Version.new(VERSION))
$logger.debug("version requirements satisfied!")
return
end
$logger.error("teracy-dev version requirements: #{requirements}")
exit 1
end
settings = YAML.load_file(File.join(File.dirname(__FILE__), 'config_default.yaml'))
Vagrant.require_version settings["vagrant"]["require_version"]
require_version(settings['teracy-dev']['require_version'])
# process settings override mechanism here
$logger.debug("settings: #{settings}")
# pre-load-ext list here
Vagrant.configure("2") do |config|
settings["nodes"].each do |node_config|
$logger.debug("node_config: #{node_config}")
config.vm.define node_config["name"] do |node|
end
end
# post-load-ext list here
end
the config override mechanism is basically the same with v0.5.0, we have "config_default.yaml" and "config_override.yaml" files respectively.
this is the working branch from my repo, we'll collaborate on that branch until we have a working version to be merged: https://github.com/hoatle/teracy-dev/tree/tasks/v0.6.0
https://github.com/hoatle/teracy-dev/blob/tasks/v0.6.0/lib/settings_processor.rb is ready to be implemented, it has the same override mechanism as v0.5.0 with additional variables_pipeline to be implemented
@phuonglm please validate the initial stuff and idea/spec from https://github.com/hoatle/teracy-dev/tree/tasks/v0.6.0 to organize implementation effort for the team.
make sure all the settings from Vagrantfile must be implemented via our config file https://www.vagrantup.com/docs/index.html we have default_config.yaml and override_config.yaml to override the default one.
https://github.com/hoatle/teracy-dev/blob/tasks/v0.6.0/lib/configurator.rb is ready to be implemented
for easier development, $ LOG_LEVEL=debug vagrant status
should be very helpful.
You can export $ export LOG_LEVEL=debug
and then $ vagrant status
https://github.com/hoatle/teracy-dev/tree/tasks/v0.6.0 is ready for preview
teracy-dev v0.6 rational:
teracy-dev v0.6 requirements:
v0.6.0
should support different providers (for example, if I prefer VMWare, Parallel or other types of providers like AWS, DO, GCE, bare metal remote host, etc.)(supported via teracy-dev-core or can create extensions to support)[ ] installer for easier on board usage(lower priority, possibly v1.0)v0.6.0
v0.6.0-c1, c2
v0.6.0-b2
v0.6.0-b1
v0.6.0-a6
v0.6.0-a5
v0.6.0-a4
v0.6.0-a3
v0.6.0-a2
v0.6.0-a1