tech:vagrant:vagrantfile

Diferències

Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.

Enllaç a la visualització de la comparació

Ambdós costats versió prèvia Revisió prèvia
Següent revisió
Revisió prèvia
tech:vagrant:vagrantfile [16/11/2021 02:51] – [vagrant: casos de uso] matetech:vagrant:vagrantfile [14/02/2022 10:45] (actual) – creat mate
Línia 1: Línia 1:
 = vagrantfile = vagrantfile
-{{NEWPAGE>tech:vagrant:vagrantfile}}+  * provisioning[[https://www.vagrantup.com/docs/provisioning]] 
 +== Vagrant.configure("2") do |config| 
 +  * config namespace: [[https://www.vagrantup.com/docs/vagrantfile/machine_settings#machine-settings]] 
 +=== box 
 +  * box a usar: **config.vm.box** 
 +    * config.vm.box="debian/bullseye64" 
 +  * versión de la box a usar: **config.vm.box_version** 
 +    * config.vm.box_version="11.20211230.1" 
 +  * dirección URL de la box: **config.vm.box_url** 
 +    * config.vm.box_url="https://app.vagrantup.com/debian/boxes/bullseye64"
  
-{{topic>Vagrantfile&nodate&nouser&sort&tags}}+=== hostname 
 +=== provision 
 +  * **name**: nombre del provisionar (para info) 
 +  * **type**: 
 +    * shell 
 +    * file 
 +  * **after**: (experimental) 
 +    * [[https://www.vagrantup.com/docs/provisioning/basic_usage#dependency-provisioners]] 
 +    * all 
 +    * each 
 +  * **before**: (experimental) 
 +    * [[https://www.vagrantup.com/docs/provisioning/basic_usage#dependency-provisioners]] 
 +    * all 
 +    * each 
 +  * communicator_required 
 +  * run 
 +    * always 
 +    * never 
 +    * once
  
 +  * inline (key/value): <code>config.vm.provision [name] type: "shell", path: "bootstrap.sh"</code>
 +  * Ruby block: <code>config.vm.provision [name] :shell, inline: "echo hello"</code>
 +    * <code>  config.vm.provision [name] "shell" do |s|
 +    s.inline = "echo hello"
 +  end</code>
 +  * <code>config.vm.provision [name] :file, path: "bootstrap.sh"</code>
  
-  * [[tech:vagrant:casosuso:tomcat]] +=== network 
-  * [[tech:vagrant:casosuso:php]] +=== sync_folder 
-  * [[tech:vagrant:casosuso:mysql]] +=== provider 
-  * [[tech:vagrant:casosuso:weblogic]] +=== define
-  * [[tech:vagrant:casosuso:3maquinas]] +
-  * [[tech:vagrant:casosuso:vagrant+docker]] +
-  * [[tech:vagrant:casosuso:master_template]] +
-  * [[tech:vagrant:casosuso:rmxnet]] +
- +
-== vagrant box +
-  * crear una box en Vagrant: +
-    - ''vagrant package <nombre_maquina> --output fichero.box'' +
-    - subir (versión, proveedor, etc...) +
-    - descargar (desde otro Vagrantfile):<code yaml; Vagrantfile></code> +
- +
-== ejemplos +
-== multi-machine cluster in a loop +
-<code ruby> +
-# -*- mode: ruby -*- +
-# vi: set ft=ruby : +
- +
-VAGRANTFILE_API_VERSION = "2" +
- +
-cluster = { +
-  "master" => { :ip => "192.168.33.10", :cpus => 1, :mem => 1024 }, +
-  "slave" => { :ip => "192.168.33.11", :cpus => 1, :mem => 1024 } +
-+
-  +
-Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| +
- +
-  cluster.each_with_index do |(hostname, info), index| +
- +
-    config.vm.define hostname do |cfg| +
-      cfg.vm.provider :virtualbox do |vb, override| +
-        config.vm.box = "ubuntu/trusty64" +
-        override.vm.network :private_network, ip: "#{info[:ip]}" +
-        override.vm.hostname = hostname +
-        vb.name = hostname +
-        vb.customize ["modifyvm", :id, "--memory", info[:mem], "--cpus", info[:cpus], "--hwvirtex", "on"+
-      end # end provider +
-    end # end config +
- +
-  end # end cluster +
-end +
-</code> +
-/via: [[https://gist.github.com/roblayton/c629683ca74658412487]] +
- +
-=== configuraciones simples +
-<sxh ruby; title: 1 máquina, varias opciones de configuración> +
-Vagrant.configure(2) do |config| +
-  config.vm.box "debian/jessie64" +
-  config.vm.hostname "prueba1" +
-  config.vm.provision "shell", path: "actualizar.sh" +
- +
-  config.vm.network :private_network, ip: "192.168.100.10" # only host +
-  config.vm.network :public_network, ip: "192.168.100.20" +
-  config.vm.network :public_network,:bridge=>"eth0" +
-  config.vm.network :forwarded_port, guest: 80, host: 8080 +
-  config.vm.synced_folder "./www","/www" +
- +
-  config.vm.provider "virtualbox" do |vb| +
-    vb.name "VM-Prueba1" +
-    vb.memory 1024 +
-    vb.cpus +
-    vb.linked_clone = true +
-    vb.gui = true +
-  end +
-end +
-</sxh> +
- +
-<sxh ruby; title: 2 máquinas> +
-  Vagrant.configure("2") do |config| +
-     config.vm.define "web" do |nodo1| +
-       nodo1.vm.box = "debian/jessie64" +
-       nodo1.vm.hostname = "web" +
-       nodo1.vm.network "public_network", bridge: "eth0" +
-       nodo1.vm.network "private_network", ip: "10.0.100.101" +
-     end +
-     config.vm.define "db" do |nodo2| +
-       nodo2.vm.box = "debian/jessie64" +
-       nodo2.vm.hostname = "db" +
-       nodo2.vm.network "private_network", ip: "10.0.100.102" +
-     end +
-   end +
-</sxh> +
  • tech/vagrant/vagrantfile.1637059887.txt.gz
  • Darrera modificació: 16/11/2021 02:51
  • per mate