More Related Content
BHyVe: The BSD Hypervisor What's hot (20)
WSL2+docker+JupyterとVS Codeリモート環境の構築 openSUSEで最強仮想環境をつくろう - ゲーミングから仮想通貨まで - OSC名古屋2017セミナー資料 2014/11/08 第3回 一撃サーバー構築シェルスクリプト勉強会(懇親会もあるよ!) 発表資料 Wocker 秒速で WordPress 開発環境を構築する XenServerとZFSストレージでサーバ仮想化 - OSC2011 Tokyo/Spring 自宅SAN友の会(後半) Docker+CoreOS+GCEで自動スケール分散レイトレ 軽快なPlan 9 Update - Illumos KVM上陸 - Ansible 2.0を使って組む kubernetesクラスタ vol.1 FreeBSD VPSでLive Migration こんてなぐらし!〜FreeBSD VPSでライブマイグレーション〜 Okinawa Open Days 2015 Handson - Ansible COMSTARでiSCSI - OpenSolaris勉強会 2011.08 Similar to 勉強会0614 vagrant (20)
Wakame Project - 自作クラウド研究会 CloudFoundry 2 on Apache CloudStack 4.2.1 ラズパイ2で動く Docker PaaSを作ってみたよ もう XAMPP / MAMP はいらない!
Vagrant で作る PHP 開発環境 クラウド環境向けZabbixカスタマイズ紹介(第5回Zabbix勉強会) ネットワークエンジニアのための Puppet / Chef More from Yu Ito (8)
徳島OSS勉強会第四回 シラサギハンズオン 0925 勉強会0614 vagrant
- 4. 用語
プロビジョニング
- vagrant upをした後に実行される一連の処理のこと
- シェルスクリプト、Chef(chef-solo, chef-client)、Puppetなどが使えます
Boxファイル
- 仮想マシン起動の際にベースとなるテンプレートファイル
- ISOファイルではありません
- 仮想環境別に必要、通常はOSイメージから作成する
- Vagrant利用の上で最低限必要な設定(ユーザの作成、sshdの起動、プロビジョニング
ツールのインストール)のみを行っておく
- 6. vagrant file
vagrant init
Vagrant.configure(2) do |config|
config.vm.box = "base"
# config.vm.box_check_update = false
# Create a forwarded port mapping
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM.
# config.vm.synced_folder "../data", "/vagrant_data"
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end
- 7. vagrant file
network
Vagrant.configure(2) do |config|
config.vm.box = "base"
# config.vm.box_check_update = false
# Create a forwarded port mapping
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM.
# config.vm.synced_folder "../data", "/vagrant_data"
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end
- 8. vagrant file
provisioning
Vagrant.configure(2) do |config|
config.vm.box = "base"
# config.vm.box_check_update = false
# Create a forwarded port mapping
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM.
# config.vm.synced_folder "../data", "/vagrant_data"
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end
- 9. vagrant コマンド
vagrant box add [box-name] [box-url]
vagrant box list
Vagrant box remove [box-name]
vagrant up 立ち上げ
vagrant halt 停止、シャットダウン
vagrant suspend 中断
vagrant resume 復帰
vagrant destroy 仮想マシン削除(Boxの削除ではない)
- 15. ss-vagrant
Vagrant.configure(2) do |config|
config.vm.box = "ss-vagrant-v1.2.0"
config.vm.box_url = https://github.com/shirasagi/ss-vagrant/releases/download/v1.2.0/ss-vagrant-virtualbox-
x86_64.box
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network "private_network", ip: "192.168.33.10“
config.vm.provider :virtualbox do |vb|
# IPv6 と DNS でのネットワーク遅延対策で追記
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
end
end
- 16. windowsでの簡単な立ち上げ方(オフライン)
1. VirtualBoxをインストール
2. vagrantをインストール
3. sshクライアントをインストール
4. VagrantFile と ss-vagrant-virtualbox-x86_64.box を用意
5. フォルダー C:vagrant を作成します
6. VagrantFile と ss-vagrant-virtualbox-x86_64.box を作成したフォルダーにコピーします
7. コマンドプロンプトを立ち上げて以下のコマンドを実行します
> cd C:vagrant
> vagrant box add ss ss-vagrant-virtualbox-x86_64.box
> vagrant up
- 18. Vagrant Box build
仮想環境上で vagrant package
packer を使う
- https://www.packer.io/downloads.html
- template.jsonを元にBoxを作成
packer build [template.json]
- centos用テンプレート: https://github.com/boxcutter/centos
- 19. Vagrant plugin
vagrant plugin install [plugin-name]
sahara
- サンドボックスモードを有効にするプラグイン
- ロールバック機能で実行前の状態に戻すことができます
vagrant-hostmanager
- HOST名の書き換え(host OS含む)