Skip to content

Instantly share code, notes, and snippets.

@u1and0
Last active February 12, 2022 01:38
Show Gist options
  • Save u1and0/44f001c5b5d1a52f126518a52ab9b0ba to your computer and use it in GitHub Desktop.
Save u1and0/44f001c5b5d1a52f126518a52ab9b0ba to your computer and use it in GitHub Desktop.
vagrant file on windows machine mount share folders
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Requied vagrant plugin
# $ vagrant plugin install [NAME]
# sahara (0.0.17, global)
# - Version Constraint: > 0
# vagrant-cachier (1.2.1, global)
# - Version Constraint: > 0
# vagrant-disksize (0.1.3, global)
# vagrant-vbguest (0.30.0, global)
# - Version Constraint: > 0
# 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/focal64"
config.vm.box_url = "https://app.vagrantup.com/ubuntu/boxes/focal64"
config.vm.boot_timeout = 600
# 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: 22, host: 1234 # ssh
config.vm.network "forwarded_port", guest: 8888, host: 8888 # jupyter
config.vm.network "forwarded_port", guest: 8080, host: 8080 # golang
config.vm.network "forwarded_port", guest: 8081, host: 8081 # golang
config.vm.network "forwarded_port", guest: 8082, host: 8082 # golang
config.vm.network "forwarded_port", guest: 8083, host: 8083 # golang
config.vm.network "forwarded_port", guest: 8084, host: 8084 # golang
config.vm.network "forwarded_port", guest: 8085, host: 8085 # golang
config.vm.network "forwarded_port", guest: 8008, host: 8008 # none
config.vm.network "forwarded_port", guest: 8000, host: 8000 # jupter-local
config.vm.network "forwarded_port", guest: 8889, host: 8889 # none
config.vm.network "forwarded_port", guest: 8890, host: 8890 # master
config.vm.network "forwarded_port", guest: 8891, host: 8891 # none
config.vm.network "forwarded_port", guest: 8880, host: 8880 # fess-fess01
config.vm.network "forwarded_port", guest: 8892, host: 8892 # fess-es01
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# 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", "/vagrant_data"
config.vm.synced_folder "../../../../../1_Information", "/mnt/1_Information", owner: "vagrant", group: "vagrant"
config.vm.synced_folder "../../../../../2_Common", "/mnt/2_Common", owner: "vagrant", group: "vagrant"
config.vm.synced_folder "../../../../../3_Personal", "/mnt/3_Personal", owner: "vagrant", group: "vagrant"
config.vm.synced_folder "../../../../../4_Restriction", "/mnt/4_Restriction", owner: "vagrant", group: "vagrant"
config.vm.synced_folder "../../../../../5_UserCommunication", "/mnt/5_UserCommunication", owner: "vagrant", group: "vagrant"
#config.vm.synced_folder "../../../../../../y/システム管理補助者", "/y/システム管理補助者", owner: "vagrant", group: "vagrant"
# config.vm.synced_folder "../../../../../../ShareTemp", "/ShareTemp", owner: "vagrant", group: "vagrant"
config.vm.synced_folder "~", "/home/vagrant/home", owner: "vagrant", group: "vagrant"
# `/home/vagrant`ではpermission deniedになる
# config.vm.synced_folder "~/.history", "/home/vagrant/.history", owner: "vagrant", group: "vagrant"
# 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|
vb.memory = 4096
vb.cpus = 4
# クリップボードの共有: 双方向
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
end
# USB=1 #false
# if USB
# config.vm.provider "virtualbox" do |vb|
# # によってUSBデバイスが確認され、
# vb.customize ["modifyvm", :id, "--usb", "on"]
# # によってデバイスフィルターに追加され、
# vb.customize ["usbfilter", 'add', '0', '--target', :id, '--name', 'Arduino', '--vendorid', '2341', '--productid', '0043']
# # によってWindows機のCOM5が、
# vb.customize ["modifyvm", :id, "--uartmode2", "client", "COM3"]
# # によってVMのCOM2に割り当てられている
# vb.customize ["modifyvm", :id, "--uart2", "0x2F8", "3"]
# end
# end
GUI=false
if GUI
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--vram", "128"]
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
end
end
# Expand disk space
if Vagrant.has_plugin?("vagrant-disksize")
config.disksize.size = '80GB'
end
# View the documentation for the provider you are using for more
# information on available options.
# 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.
# run as root=>True, run as user=>False
# config.vm.provision :shell, :path => "bootstrap.sh", :privileged => false
#
# docker for apt設定参考
# https://qiita.com/tkyonezu/items/0f6da57eb2d823d2611d
config.vm.provision "shell", inline: <<-SHELL
: "一度でもprovisionを実行していたら終了" &&\
test -f /etc/bootstrapped && exit
: "関連パッケージインストール" &&\
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
: "フィンガプリント" &&\
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
: "リポジトリ追加" &&\
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
: "docker install" &&\
apt update && apt-get install -y docker-ce
: "docker-compose install" &&\
export VERSION='1.29.2'
curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod 0755 /usr/local/bin/docker-compose
: "custom aliases"
echo "alias docker='sudo docker '" >> /home/vagrant/.bash_aliases
echo "alias docker-compose='sudo docker-compose '" >> /home/vagrant/.bash_aliases
echo "alias du='du -h '" >> /home/vagrant/.bash_aliases
: "実行内容を/etc/bootstrappedへ出力" &&\
cat $0 > /etc/bootstrapped
SHELL
config.ssh.insert_key=false # root user ssh for sharing with windows machine
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment