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:13] – Édson Kuzniewski | vagrant:create_box [2022/05/25 16:24] (atual) – edição externa 127.0.0.1 | ||
---|---|---|---|
Linha 1: | Linha 1: | ||
- | ====== | + | ====== |
+ | [[http:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
- | [[https://github.com/ | + | ====== Create a BOX ====== |
+ | {{:vagrant: | ||
+ | set **USER** and **PASSWORD** define '' | ||
+ | set **PASSWORD** root define '' | ||
+ | < | ||
+ | $ sudo apt-get install dkms | ||
+ | $ sudo apt-get install | ||
+ | </ | ||
+ | {{: | ||
+ | < | ||
+ | $ sudo mount /dev/cdrom / | ||
+ | $ sudo / | ||
+ | $ sudo umount / | ||
+ | $ sudo apt-get clean | ||
- | [[http://blog.eriksen.com.br/pt-br/criando-boxes-vagrant-customizados-com-veewee|Criando boxes Vagrant customizados com o Veewee]] | + | $ sudo /etc/init.d/vboxadd setup |
+ | $ sudo apt-get update -y | ||
+ | </code> | ||
- | Eu já falei um pouco sobre o Vagrant e sobre a filosofia DevOps. No post sobre Vagrant mostrei como usar um box Ubuntu publicamente disponível e quão fácil é usar um provisionador shell para configurar um box LAMP básico. | + | ===== Add the vagrant user to sudoers file ===== |
+ | < | ||
+ | $ sudo echo " | ||
+ | $ sudo chmod 0440 / | ||
+ | </ | ||
- | 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. | + | ===== Install Vagrant Public Keys ===== |
+ | < | ||
+ | $ mkdir ~/.ssh | ||
+ | $ wget -qO- https://raw.github.com/mitchellh/ | ||
- | E por que não criar um box base? Veewee ao resgate! | + | # Ensure we have the correct permissions set |
- | + | $ chmod 0700 /home/vagrant/.ssh | |
- | ===== Veewee ===== | + | $ chmod 0600 /home/vagrant/.ssh/authorized_keys |
- | + | $ chown -R vagrant | |
- | O [[https://github.com/jedi4ever/ | + | </ |
- | + | ||
- | < | + | |
- | ==== ERRO 1 ==== | + | ===== Install OpenSSH Server ===== |
< | < | ||
- | $ 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.1406319187.txt.gz · Última modificação: 2022/05/25 16:25 (edição externa)