æ£ç´ruby on windowsã§ããããããã®ç²ããã®ã§ãVMå ¥ãã¦Linuxå ¥ãã¦ã£ã¦æã£ããã ãã©ãè¨å®å¤±æããããããã³ã«æåããããç´ãã¨ããããããããªããªãã²ã¹ãOSã®ããã¯ã¢ããåã£ã¦ããã¨ããããã¾ãããããªãã¤ãã¿ãä¼´ãã®ã§ãVagrantã£ã¦ã®ã使ãã°ããã§ãããããã¨ããã®ããããã§è¦ãã®ã§ãã£ã¦ããããã
ã¤ã³ã¹ãã¼ã«
ããã¿ãªãããã£ã
ãã¨ããã»ãã¨åèã«ãªã
- https://gist.github.com/voluntas/5525719
- ãã¼ã¹ã®boxã¯ããããããããé¸ã¹ã¦ããã便å©
2ã¾ã§ã¯ã¾ãã¾åãæé
- vagrantãå ¥ã£ã¦ãã確èª
vagrant -v Vagrant version 1.2.7
3ã¯ç¾æç¹ã®ææ°ã®ãã¼ã¸ã§ã³ãå ¥ãã
- addã§boxããã£ãã·ã¥ï¼ããããã
vagrant box add centos
http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
- åç·ã«ããããã©ãããé·ã
- ãã£ããã©ãã«ã¤ã¡ã¼ã¸ãä¿åãã¦ããã®ãâ¦
- ãã£ã
- ãã£ããã©ãã«ã¤ã¡ã¼ã¸ãä¿åãã¦ããã®ãâ¦
C:\Users\username\.vagrant.d\boxes\centos\virtualbox
- addçµãã
Downloading or copying the box... Extracting box...ate: 147k/s, Estimated time remaining: --:--:--) Successfully added box 'centos' with provider 'virtualbox'!
- initãã
- Vagrantfileï¼è¨å®ãã¡ã¤ã«ï¼ï¼ãä½ãã£ã½ã
vagrant init centos A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.
-
- Vagrantfileä½ã£ãããèªãã¨ãæ¸ãã¦ããã©ãã©ãã«ä½ããããäºã調ã¹ã¨ããªãã¨è¦ããã¨ããã§ããªã
- Linuxãªã ~/.vagrant ã«ã§ããã£ã½ã
- Vagrantfileä½ã£ãããèªãã¨ãæ¸ãã¦ããã©ãã©ãã«ä½ããããäºã調ã¹ã¨ããªãã¨è¦ããã¨ããã§ããªã
- upãã
- å ¥ããcentosãèµ·åãã
vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Importing base box 'centos'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... [default] Clearing any previously set forwarded ports... [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Booting VM... [default] Waiting for VM to boot. This can take a few minutes. [default] VM booted and ready for use! [default] Mounting shared folders... [default] -- /vagrant
- statusãã
- åãã¦ãã確èªãã
vagrant status Current machine states: default running (virtualbox) The VM is running. To stop this VM, you can run `vagrant halt` to shut it down forcefully, or you can run `vagrant suspend` to simply suspend the virtual machine. In either case, to restart it again, simply run `vagrant up`.
-
- åãã¦ãã£ã½ã
- vagrant haltã§æ®ºãã
- åãã¦ãã£ã½ã
- sshãã
- ãã°ã¤ã³ã§ããã確èªãã
vagrant ssh `ssh` executable not found in any directories in the %PATH% variable. Is an SSH client installed? Try installing Cygwin, MinGW or Git, all of which contain an SSH client. Or use the PuTTY SSH client with the following authentication information shown below: Host: 127.0.0.1 Port: 2222 Username: vagrant Private key: C:/Users/username/.vagrant.d/insecure_private_key
login as: vagrant [email protected]'s password: Last login: Wed Aug 14 08:07:51 2013 from 10.0.2.2 Welcome to your Vagrant-built virtual machine. [vagrant@localhost ~]$ ruby -v ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
-
- æ®éã«åãã¦ããã
saharaå ¥ãã
- ãµã³ãããã¯ã¹ã§rollbackã¨ãã§ããã£ã½ã
- https://github.com/jedi4ever/sahara
vagrant plugin install sahara
snapshotå ¥ãã
- ãããrollbackã§ããã¨ã¯ããããæç¹ã§ã®ç°å¢ã¯æ°¸ç¶çã«ä¿åãã¦ãããããã§
- https://gist.github.com/voluntas/5525719
vagrant plugin install vagrant-vbox-snapshot # ã¹ãããã·ã§ãããååãæå®ãã¦åå¾ãã¾ã $ vagrant snapshot take <name> # ä¸çªææ°ã®ã¹ãããã·ã§ããã«æ»ãã¾ã $ vagrant snapshot back # ã¹ãããã·ã§ããä¸è¦§ã表示ãã¾ã $ vagrant snapshot list # ã¹ãããã·ã§ãããåé¤ãã¾ã $ vagrant snapshot delete <name> # æå®ããã¹ãããã·ã§ãã(åå)ã«æ»ãã¾ã $ vagrant snapshot go <name>
- takeãã¦ãlistãã¦ããªãã®åå¿ããªã
- ã©ããããã¨ãªã®ãâ¦
çµäºãã
vagrant halt [default] Attempting graceful shutdown of VM...
ã¾ãèµ·åãã
vagrant up
ã¶ã£å£ã
- destroyãã¦ãboxèªä½ã¯æ®ã£ã¦ãã£ã½ã
vagrant destroy Are you sure you want to destroy the 'default' VM? [y/N] y [default] Destroying VM and associated drives...
- boxãæ¶ã
vagrant box remove boxå
- boxã®ä¸è¦§
vagrant box list
ãã®å¾
boxåã«centosã£ã¦ã¤ãã¡ãã£ã¦centos6ã«ããããªã£ã¦æã£ã¦renameæ¹æ³æ¢ãããã©ããããããªãã£ãã®ã§ãdestroyãã¦removeãã¦ã¾ãaddãã¦initããã
`Vagrantfile` already exists in this directory. Remove it before running `vagrant init`
ã£ã¦åºã¦ãã®ã§ãcentos6ã®ãã©ã«ãã«å
¥ã£ã¦ãVagrantfileãæ¶ãã¦ã¾ãinitãã¦ãåãã®ãåºã¦ãã¡ã ã£ãã
ããã£ã¦ãããããªãã£ããã ãã©ãupã¨ããã¦ã¿ãã¨ã©ããåã®centosãèµ·åãã«è¡ã£ã¦ãã£ã½ãã£ãã®ã§ããªããã®è¨å®ãã¡ã¤ã«ã«ã¡ããã¨defaultã®boxåãå¤ãã£ã¦ããªãã£ã½ãç¾è±¡ãªæ°ãããã
boxesã®ä¸ã«centosã£ã¦åã®boxã®ãã©ã«ãï¼ä¸èº«ã¯å½ç¶ç©ºï¼ããã£ãã®ã§ãcentosãcentos6ãæ¶ãã¦å度addãã¦ã¿ããã©ã ãã ã£ãã
解決
æå³ããã£ã¨ããã£ãã
Vagrantã®ä»®æ³ãã·ã³ãåããç°å¢ãã¡ã¤ã«ã¨ãã¯èªåã§å¥½ããªã¨ããã«ä½ããã£ã¦ãã¨ã£ã½ãã
addãããã£ã¨cmd.exeå©ããã¨ãã®ãã¼ã ãã£ã¬ã¯ããªã®ã¾ã¾ã§ãã£ã¦ãã®ã§ãå¿
ç¶çã«
C:/Users/username/
ã§ãã£ã¦ã¦ãããã§
vagrant init
ã£ã¦ãã㨠C:/Users/username/ ç´ä¸ã«ãVagrantfileããã§ãã¦ãããã«ã¯ããæ¶ãã¦ããcentosã£ã¦boxåã
config.vm.box = "centos"
ãã®ã¾ã¾ãã£ã¨æ®ã£ã¦ããããC:/Users/username/ ã§å»¶ã
initãã£ã¦ãããã確ãã«centosãèµ·åãã«è¡ãã¾ããã£ã¦æãã ã£ãã
ãªã®ã§ãC:\Users\username\.vagrant.d\boxes ã®ä¸ã® Vagrantfile ãæ¶ãã¦ããªãã®è§£æ±ºãããªãä¸ã«ããã® Vagrantfile ã¯VMãåããã¨ãã«ä½¿ããããããæ¶ãã¦ãã¡ã£ã¦ãã¨ã£ã½ãã
æå³ããããã°ç°¡åãªãã¨ã§ããã®ã¾ã¾ãããããã°ãã¼ã ãã©ã«ãä¸ã® Vagrantfile ãæ¶ãã¦initãç´ãã°ããããOSãã¨ã«ç°å¢åããããã°é©å½ã«ãã©ã«ãä½ã£ã¦ããã§initãã¦ãã¾ãã°ããã ãã ã£ãã
ãµã¼ãã«ããããå ¥ãã¦ã¿ã
Chefã£ã¦ããã®ã§è¨å®æ¸ãã°èªåã§ã¤ã³ã¹ãã¼ã«ã§ããããããã©ãããããããã©ãããããªæããããã®ã§Ansibleã£ã¦ãã·ã³ãã«ãããã¨ãããã¨ãªã®ã§ã次åã¯ããã使ã£ã¦ãããããã£ã¦ããããã