vagrant_configyaml - choisungwook/portfolio GitHub Wiki

๊ฐœ์š”

  • vagrant์—์„œ yamlํŒŒ์ผ ๋กœ๋“œ
  • ์ฃผ๋กœ ์„ค์ •ํŒŒ์ผ์„ yamlํŒŒ์ผ์— ์„ค์ •ํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค.

์„ธ๋ถ€ ๋‚ด์šฉ

  • config.yaml์€ vagrant์™€ ๊ฐ™์€ ๊ฒฝ๋กœ์— ์กด์žฌํ•ด์•ผ ํ•œ๋‹ค.
  • vagrant๋Š” yaml ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋กœ๋“œํ•ด์•ผ ํ•œ๋‹ค.

config.yaml

---
server1:  
  name: server1
  box: centos/7
  hostname: test-server1
  ip: 192.168.25.188"
  memory: 2048
  cpu: 2

vagrant

require 'yaml'

CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), 'config.yml'))

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false

  config.vm.define CONFIG['server1']['name'] do |cfg|
    cfg.vm.box = CONFIG['server1']['box']
    cfg.vm.network "public_network", ip: CONFIG['server1']['ip']
    cfg.vm.hostname = CONFIG['server1']['hostname']
    
    cfg.vm.provider "virtualbox" do |v|
      v.memory = CONFIG['server1']['memory']
      v.cpus = CONFIG['server1']['cpu']
      v.name = CONFIG['server1']['hostname']
    end
  end
end

์ฐธ๊ณ ์ž๋ฃŒ

โš ๏ธ **GitHub.com Fallback** โš ๏ธ