vagrant 基本命令、标准配置文件,支持nfs

来源:互联网 发布:郑州淘宝加盟宣判了吗 编辑:程序博客网 时间:2024/05/17 23:39
vagrant基本命令:vagrant init 初始化仓库vagrant box add 别名 xxx.boxvagrant up 开始安装镜像到virtualboxvagrant ssh 进入镜像的sshvagrant halt 关机
# -*- mode: ruby -*-# vi: set ft=ruby :# All Vagrant configuration is done below. The "2" in Vagrant.configure# configures the configuration version (we support older styles for# backwards compatibility). Please don't change it unless you know what# you're doing.Vagrant.configure("2") do |config|  # The most common configuration options are documented and commented below.  # For a complete reference, please see the online documentation at  # https://docs.vagrantup.com.  # Every Vagrant development environment requires a box. You can search for  # boxes at https://atlas.hashicorp.com/search.  config.vm.box = "ubuntu/xenial64"  # Disable automatic box update checking. If you disable this, then  # boxes will only be checked for updates when the user runs  # `vagrant box outdated`. This is not recommended.  # config.vm.box_check_update = false  # Create a forwarded port mapping which allows access to a specific port  # within the machine from a port on the host machine. In the example below,  # accessing "localhost:8080" will access port 80 on the guest machine.  # config.vm.network "forwarded_port", guest: 80, host: 8080  # Create a private network, which allows host-only access to the machine  # using a specific IP.  config.vm.network "private_network", ip: "192.168.6.7"  # Create a public network, which generally matched to bridged network.  # Bridged networks make the machine appear as another physical device on  # your network.  # config.vm.network "public_network"  # Share an additional folder to the guest VM. The first argument is  # the path on the host to the actual folder. The second argument is  # the path on the guest to mount the folder. And the optional third  # argument is a set of non-required options.  config.vm.synced_folder "../data", "/data"  # Provider-specific configuration so you can fine-tune various  # backing providers for Vagrant. These expose provider-specific options.  # Example for VirtualBox:  #  # 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  #  # View the documentation for the provider you are using for more  # information on available options.  config.vm.provider "virtualbox" do |vb|    vb.memory = "4096"  end  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies  # such as FTP and Heroku are also available. See the documentation at  # https://docs.vagrantup.com/v2/push/atlas.html for more information.  # config.push.define "atlas" do |push|  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"  # end  # Enable provisioning with a shell script. Additional provisioners such as  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the  # documentation for more information about their specific syntax and use.  # config.vm.provision "shell", inline: <<-SHELL  #   apt-get update  #   apt-get install -y apache2  # SHELLend


-----20170424更新配置


# -*- mode: ruby -*-# vi: set ft=ruby :# All Vagrant configuration is done below. The "2" in Vagrant.configure# configures the configuration version (we support older styles for# backwards compatibility). Please don't change it unless you know what# you're doing.Vagrant.configure("2") do |config|  # The most common configuration options are documented and commented below.  # For a complete reference, please see the online documentation at  # https://docs.vagrantup.com.  # Every Vagrant development environment requires a box. You can search for  # boxes at https://atlas.hashicorp.com/search.  config.vm.box = "gbarbieru/xenial"  # Disable automatic box update checking. If you disable this, then  # boxes will only be checked for updates when the user runs  # `vagrant box outdated`. This is not recommended.  # config.vm.box_check_update = false  # Create a forwarded port mapping which allows access to a specific port  # within the machine from a port on the host machine. In the example below,  # accessing "localhost:8080" will access port 80 on the guest machine.  config.vm.network "forwarded_port", guest: 80, host: 8080  # Create a private network, which allows host-only access to the machine  # using a specific IP.  config.vm.network "private_network", ip: "6.6.6.6"  # Create a public network, which generally matched to bridged network.  # Bridged networks make the machine appear as another physical device on  # your network.  # config.vm.network "public_network"  # Share an additional folder to the guest VM. The first argument is  # the path on the host to the actual folder. The second argument is  # the path on the guest to mount the folder. And the optional third  # argument is a set of non-required options.  config.vm.synced_folder "../data", "/data", :nfs =>{    :linux__nfs_options => ["rw","all_squash","anonuid=1000","anongid=1000"],    :map_uid => 0,    :map_gid => 0  },  nfs_udp: false  # Provider-specific configuration so you can fine-tune various  # backing providers for Vagrant. These expose provider-specific options.  # Example for VirtualBox:  #  # 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  #  # View the documentation for the provider you are using for more  # information on available options.  config.vm.provider "virtualbox" do |vb|    vb.memory = "4096"  end  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies  # such as FTP and Heroku are also available. See the documentation at  # https://docs.vagrantup.com/v2/push/atlas.html for more information.  # config.push.define "atlas" do |push|  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"  # end  # Enable provisioning with a shell script. Additional provisioners such as  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the  # documentation for more information about their specific syntax and use.  # config.vm.provision "shell", inline: <<-SHELL  #   apt-get update  #   apt-get install -y apache2  # SHELLend


---2017年7月3日20:41:24  支持脚本

# -*- mode: ruby -*-  # vi: set ft=ruby :      # All Vagrant configuration is done below. The "2" in Vagrant.configure  # configures the configuration version (we support older styles for  # backwards compatibility). Please don't change it unless you know what  # you're doing.  Vagrant.configure("2") do |config|    # The most common configuration options are documented and commented below.    # For a complete reference, please see the online documentation at    # https://docs.vagrantup.com.        # Every Vagrant development environment requires a box. You can search for    # boxes at https://atlas.hashicorp.com/search.    config.vm.box = "centos_v68"        # Disable automatic box update checking. If you disable this, then    # boxes will only be checked for updates when the user runs    # `vagrant box outdated`. This is not recommended.    # config.vm.box_check_update = false        # Create a forwarded port mapping which allows access to a specific port    # within the machine from a port on the host machine. In the example below,    # accessing "localhost:8080" will access port 80 on the guest machine.   config.vm.network "forwarded_port", guest: 80, host: 8080    config.vm.network "forwarded_port", guest: 22, host: 22        # Create a private network, which allows host-only access to the machine    # using a specific IP.    config.vm.network "private_network", ip: "10.0.0.1"        # Create a public network, which generally matched to bridged network.    # Bridged networks make the machine appear as another physical device on    # your network.    # config.vm.network "public_network"      config.vm.provision "shell", inline: <<-SHELL    rm -rf /root/.ssh    ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''    echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4LREGtYcyQOkct6B5IgcBXsyDp2ntfUvrs4NDQ5cztrksq3ixhLYzC50xdtVeTgFJNjeNxl4+WnKSHXDuHquZr2I7gmH29pv2iZZSVbBhRZtUX6NpHs700DZvdQ88TtCxe5SXM5lJLJ1oo6OLsKrvowd7DD3/l/rBpoNRNf81dOldQnN96VtHQctmQAZkhl/3ldSXcRre/xSD0AXIR8VAn+XOBCgR2S0rjk4Irz29R2mN3aIXx01gwiQGm01ldDoU/vw6AX/6DuP8tXV9kYvETU3mkhtA1x+z05mvoe6zkCM6+WfztzCXUDoikMbINnTTrx7VhkYR6SJ2Ff2LKubiQ== root@CentOS-PHP3' > /root/.ssh/authorized_keys  SHELL    # Share an additional folder to the guest VM. The first argument is    # the path on the host to the actual folder. The second argument is    # the path on the guest to mount the folder. And the optional third    # argument is a set of non-required options.    config.ssh.username = "vagrant"  config.ssh.password = "vagrant"  config.vm.synced_folder "E:/data", "/data"    # config.vm.synced_folder "E:/data", "/data", :nfs =>{    #   :linux__nfs_options => ["rw","all_squash","anonuid=1000","anongid=1000"],    #   :map_uid => 0,    #   :map_gid => 0    # },    # nfs_udp: false        # Provider-specific configuration so you can fine-tune various    # backing providers for Vagrant. These expose provider-specific options.    # Example for VirtualBox:    #    # 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    #    # View the documentation for the provider you are using for more    # information on available options.    config.vm.provider "virtualbox" do |vb|      vb.memory = "4096"    end        # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies    # such as FTP and Heroku are also available. See the documentation at    # https://docs.vagrantup.com/v2/push/atlas.html for more information.    # config.push.define "atlas" do |push|    #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"    # end        # Enable provisioning with a shell script. Additional provisioners such as    # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the    # documentation for more information about their specific syntax and use.    # config.vm.provision "shell", inline: <<-SHELL    #   apt-get update    #   apt-get install -y apache2    # SHELL  end  

---2017年7月7日11:40:41    支持 配置  共享目录的所属用户 和组

# -*- mode: ruby -*-  # vi: set ft=ruby :      # All Vagrant configuration is done below. The "2" in Vagrant.configure  # configures the configuration version (we support older styles for  # backwards compatibility). Please don't change it unless you know what  # you're doing.  Vagrant.configure("2") do |config|    # The most common configuration options are documented and commented below.    # For a complete reference, please see the online documentation at    # https://docs.vagrantup.com.        # Every Vagrant development environment requires a box. You can search for    # boxes at https://atlas.hashicorp.com/search.    config.vm.box = "centos_v68"        # Disable automatic box update checking. If you disable this, then    # boxes will only be checked for updates when the user runs    # `vagrant box outdated`. This is not recommended.    # config.vm.box_check_update = false        # Create a forwarded port mapping which allows access to a specific port    # within the machine from a port on the host machine. In the example below,    # accessing "localhost:8080" will access port 80 on the guest machine.   config.vm.network "forwarded_port", guest: 80, host: 8080    config.vm.network "forwarded_port", guest: 22, host: 22        # Create a private network, which allows host-only access to the machine    # using a specific IP.    config.vm.network "private_network", ip: "10.0.0.8"        # Create a public network, which generally matched to bridged network.    # Bridged networks make the machine appear as another physical device on    # your network.    # config.vm.network "public_network"      config.vm.provision "shell", inline: <<-SHELL    rm -rf /root/.ssh    ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''    echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4LREGtYcyQOkct6B5IgcBXsyDp2ntfUvrs4NDQ5cztrksq3ixhLYzC50xdtVeTgFJNjeNxl4+WnKSHXDuHquZr2I7gmH29pv2iZZSVbBhRZtUX6NpHs700DZvdQ88TtCxe5SXM5lJLJ1oo6OLsKrvowd7DD3/l/rBpoNRNf81dOldQnN96VtHQctmQAZkhl/3ldSXcRre/xSD0AXIR8VAn+XOBCgR2S0rjk4Irz29R2mN3aIXx01gwiQGm01ldDoU/vw6AX/6DuP8tXV9kYvETU3mkhtA1x+z05mvoe6zkCM6+WfztzCXUDoikMbINnTTrx7VhkYR6SJ2Ff2LKubiQ== root@CentOS-PHP3' > /root/.ssh/authorized_keys  SHELL    # Share an additional folder to the guest VM. The first argument is    # the path on the host to the actual folder. The second argument is    # the path on the guest to mount the folder. And the optional third    # argument is a set of non-required options.    config.ssh.username = "vagrant"  config.ssh.password = "vagrant"  config.vm.synced_folder "E:/data", "/data",create: true, owner:"vagrant", group: "www"    # config.vm.synced_folder "E:/data", "/data", :nfs =>{    #   :linux__nfs_options => ["rw","all_squash","anonuid=1000","anongid=1000"],    #   :map_uid => 0,    #   :map_gid => 0    # },    # nfs_udp: false        # Provider-specific configuration so you can fine-tune various    # backing providers for Vagrant. These expose provider-specific options.    # Example for VirtualBox:    #    # 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    #    # View the documentation for the provider you are using for more    # information on available options.    config.vm.provider "virtualbox" do |vb|      vb.memory = "4096"    end        # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies    # such as FTP and Heroku are also available. See the documentation at    # https://docs.vagrantup.com/v2/push/atlas.html for more information.    # config.push.define "atlas" do |push|    #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"    # end        # Enable provisioning with a shell script. Additional provisioners such as    # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the    # documentation for more information about their specific syntax and use.    # config.vm.provision "shell", inline: <<-SHELL    #   apt-get update    #   apt-get install -y apache2    # SHELL  end  


0 0