vagrant:create_box
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
| Ambos lados da revisão anteriorRevisão anteriorPróxima revisão | Revisão anterior | ||
| vagrant:create_box [2014/07/25 17:16] – Édson Kuzniewski | vagrant:create_box [2014/08/06 16:59] (atual) – Édson Kuzniewski | ||
|---|---|---|---|
| Linha 1: | Linha 1: | ||
| ====== Links para ver ====== | ====== Links para ver ====== | ||
| + | [[http:// | ||
| + | [[https:// | ||
| + | [[https:// | ||
| - | [[https://github.com/ | + | ====== Create a BOX ====== |
| - | [[https://github.com/ckan/ckan/wiki/How-to-Create-a-CentOS-Vagrant-Base-Box]]\\ | + | {{:vagrant: |
| - | [[http://aruizca.com/steps-to-create-a-vagrant-base-box-with-ubuntu-14-04-desktop-gui-and-virtualbox/ | + | set **USER** and **PASSWORD** define '' |
| + | set **PASSWORD** root define '' | ||
| + | < | ||
| + | $ sudo apt-get install dkms | ||
| + | $ sudo apt-get install | ||
| + | </ | ||
| + | {{:vagrant:vitualbox-guest-addtions.png? | ||
| + | < | ||
| + | $ sudo mount /dev/cdrom /media/cdrom | ||
| + | $ sudo /media/cdrom/VBoxLinuxAdditions.run | ||
| + | $ sudo umount | ||
| + | $ sudo apt-get clean | ||
| - | ====== Create BOX ====== | + | $ sudo / |
| + | $ sudo apt-get update -y | ||
| + | </ | ||
| - | [[http://blog.eriksen.com.br/pt-br/criando-boxes-vagrant-customizados-com-veewee|Criando boxes Vagrant customizados com o Veewee]] | + | ===== Add the vagrant user to sudoers file ===== |
| + | < | ||
| + | $ sudo echo " | ||
| + | $ sudo chmod 0440 / | ||
| + | </ | ||
| - | Eu já falei um pouco sobre o Vagrant | + | ===== Install |
| + | < | ||
| + | $ mkdir ~/.ssh | ||
| + | $ wget -qO- https:// | ||
| - | Então eu disse que existem boxes publicamente disponíveis mas omiti o site [[http://www.vagrantbox.es/|Vagrant boxes]]. Por que da omissão? Simplesmente eu não os acho tão úteis e acho que as desvantagens superam os benefícios. Pegar um box que você não sabe como foi coonfigurado por levar a sérios problemas de segurança. E se o box é apenas uma instalação básica, é quase sem real utilidade já que você precisará fazer o provisionamento da sua configuração desejada a cada vez que iniciar uma VM baseada no box. | + | # Ensure we have the correct permissions set |
| + | $ chmod 0700 /home/ | ||
| + | $ chmod 0600 / | ||
| + | $ chown -R vagrant / | ||
| + | </ | ||
| - | E por que não criar um box base? Veewee ao resgate! | + | ===== Install OpenSSH Server |
| - | + | ||
| - | ===== Veewee | + | |
| - | + | ||
| - | O [[https:// | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | ==== ERRO 1 ==== | + | |
| < | < | ||
| - | $ sudo gem install | + | $ sudo apt-get |
| - | ERROR: | + | $ sudo vi /etc/ssh/ |
| - | Unable to resolve dependencies: | + | |
| </ | </ | ||
| - | + | ==== Ensure the following is set ==== | |
| - | === Correção | + | |
| < | < | ||
| - | $ sudo gem install net-scp | + | Port 22 |
| + | PubKeyAuthentication yes | ||
| + | AuthorizedKeysFile %h/ | ||
| + | PermitEmptyPasswords no | ||
| </ | </ | ||
| - | e tente novamente | ||
| - | |||
| - | ==== ERRO 2 ==== | ||
| < | < | ||
| - | Building native extensions. | + | $ sudo service ssh restart |
| - | ERROR: | + | </ |
| - | ERROR: Failed to build gem native extension. | + | |
| - | / | + | ===== GRUB ===== |
| - | / | + | Run Gedit as root (gksu gedit).\\ |
| - | from /usr/lib/ruby/ | + | \\ |
| - | from extconf.rb: | + | Open '' |
| - | + | <code> | |
| - | + | GRUB_HIDDEN_TIMEOUT=0 | |
| - | Gem files will remain installed in / | + | GRUB_HIDDEN_TIMEOUT_QUIET=true |
| - | Results logged to / | + | |
| </ | </ | ||
| - | === Correção === | + | Change the values as follows: |
| < | < | ||
| - | $ sudo apt-get install ruby-dev | + | GRUB_HIDDEN_TIMEOUT=10 |
| - | $ sudo gem install hpricot | + | GRUB_HIDDEN_TIMEOUT_QUIET=false |
| - | $ sudo gem install optiflag | + | |
| </ | </ | ||
| + | Save and run '' | ||
| - | Veewee vem com muitos templates de sistemas operations que você pode usar para criar seu box base Vagrant | + | ===== Create |
| - | + | Asuming you already have Vagrant installed | |
| - | < | + | |
| - | Existem templates para distros Linux populares (Debian, Ubuntu, CentOS, Scientific Linux), alguns sabores Unix (Solaris, FreeBSD) e até mesmo a preview release 8 do Windows. Vamos criar um box Debian. Primeiro, vamos definir o nosso box base com o nome ' | + | |
| - | + | ||
| - | < | + | |
| - | $ cd ~/ | + | |
| - | $ vagrant basebox define squeeze64-lamp Debian-6.0.4-amd64-netboot | + | |
| - | [vagrant] The basebox ' | + | |
| - | [vagrant] You can now edit the definition files stored | + | |
| - | [vagrant] vagrant basebox build ' | + | |
| - | Nós podemos ver alguns arquivos no diretório definitions/ | + | |
| - | + | ||
| - | < | + | |
| - | base.sh | + | |
| - | chef.sh | + | |
| - | O principal arquivo aqui é o definition.rb. Ele tem um hash com algumas definições da VM VirtualBox (como o número de CPUs e tamanhos de memória e disco), definições de boot e do Kickstart - que são usadas para automatizar a instalação do sistema operacional - e os arquivos de pós-instalação. Vamos configurar o mesmo box LAMP do post sobre [[http:// | + | |
| < | < | ||
| - | : | + | $ vagrant package –-base < |
| - | " | + | </ |
| - | " | + | ==== Install the box ==== |
| - | " | + | < |
| - | " | + | $ vagrant |
| - | " | + | </ |
| - | " | + | ==== Init a Vagrant Box by referencing the Base one we have created ==== |
| - | " | + | < |
| - | " | + | $ vagrant init {boxname} |
| - | " | + | </ |
| - | " | + | ==== Edit the generated Vagrantfile by uncommenting the following lines ==== |
| - | " | + | To show window VM |
| - | " | + | < |
| - | " | + | config.vm.provider |
| - | " | + | v.gui = true |
| - | " | + | end |
| - | " | + | </ |
| - | ],</ | + | ==== Spin it up! ==== |
| - | Dica: coloque seus arquivos de pós-instalação após o arquivo base.sh e antes do arquivo cleanup.sh. | + | < |
| + | $ vagrant up | ||
| + | </ | ||
| - | Com tudo no lugar, cria seu box! Isto pode levar algum tempo já que será feito o download do Virtual Box Guest Additions e da imagem ISO do sistema operacional (mas apenas para a primeira vez). | + | ==== ERROR ==== |
| + | <file sh ifup_eth1> | ||
| + | ERROR: | ||
| + | The following SSH command responded with a non-zero exit status. | ||
| + | Vagrant assumes that this means the command failed! | ||
| + | /sbin/ip addr flush dev eth1 2> /dev/null | ||
| + | Stdout from the command: | ||
| + | Stderr from the command: | ||
| + | stdin: is not a tty | ||
| - | < | + | SOLUTION: |
| - | Após criar o box, valide-o: | + | Ssh into the machine |
| - | + | Delete the file /etc/udev/rules.d/70-persistent-net.rules | |
| - | < | + | Exit the machine |
| - | Com os testes ok, exporte seu box: | + | Do a "vagrant |
| - | + | I think that does the trick =] | |
| - | < | + | </file> |
| - | Agora você tem um box base Vagrant customizado ao qual pode distribuir para o seu time de TI. Apenas adicione-o no Vagrant e comece a usá-lo! | + | |
| - | + | ||
| - | < | + | |
| - | $ vagrant init squeeze64-lamp | + | |
| - | $ vagrant up | + | |
| - | $ vagrant ssh</code> | + | |
vagrant/create_box.1406319417.txt.gz · Última modificação: (edição externa)
