DevOps
  • DevOps
  • Docker
    • Overview
  • Vagrant
    • Overview
    • Installation
    • Basic Commands
    • Vagrantfile
      • Example
    • Deploying Multiple Machine
    • Distribution
    • Reference
  • Running SQL Server on Windows Docker
    • Introduction
      • Windows Container & Hyper-V Container
    • System Requirements and Prerequisites
    • Version Compatibility
    • Enable Hyper-V & Containers and Install Docker on Window Servers
    • Using Docker to Run MSSQL Image
    • Install SSMS for remoting MSSQL Server Image
    • Using Docker-Compose to Build Up a MSSQL Image
    • Increase the default Windows container's storage
    • Reference
    • Appendix
  • Kubernetes
    • Install Kubernetes with kubeasz
    • Use Hyper-V Manager to create VM for K8S
      • Specification of the VM
      • Use Hyper-V Manager to turn on a VM for K8S
    • Installation
      • Install VirtualBox and its extension on Ubuntu
      • Install kubectl
      • Install minikube
    • Getting Started
      • Running Kubernetes Locally via Minikube
    • Assign Memory Resources to Containers and Pods
    • Assign CPU Resources to Containers and Pods
    • Quality of Services (QoS)
    • Volume for Storage
      • Configure a Pod to Use a Volume for Storage
      • *Configure a Pod to Use a PersistentVolume for Storage
    • In a nutshell...
    • Reference
  • Ansible
    • What is Ansible?
    • Set Up OS Environments for Ansible
    • Install Ansible
    • Structure for ansible
      • Inventory
      • Playbook
      • Modules
      • Variables
      • Conditions
    • Security - Ansible Fault
    • 實際操作測試1 - 使用ssh
    • 實際操作測試2 - Docker容器部署
    • Appendix
    • Reference
  • Azure
    • Overview
    • Terms
    • Getting Started
    • Azure DevOps Services
    • Reference
Powered by GitBook
On this page

Was this helpful?

  1. Vagrant

Vagrantfile

The syntax of vagrant file is not like others, its format does not like JSON/XML/TOML etc. Instead, it likes a script (ruby).

Vagrant.configure("2) do |config|    # Indicates the configuration version, there are different configuration file version.
    # config.xxx.yyy is the actual config params, xxx is the namespace and yyy is the params

    # The base image of the vagrant
    config.vm.box = "ubuntu/xenial64"

    # Set Ture for checking if box update is available in `vagrant up`, passive download, only show hint
    config.vm.box_check_update = False    

    # Configure the hostname
    config.vm.hostname = "ubuntu-test"

	# For network configuration
	# Port forwarding, 0.0.0.0:8080 -> guest:80
	config.vm.network "forwarded_port", guest: 80, host: 8080
	# Port forwarding, 127.0.0.1:8080 -> guest:80
	config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"	
	# assign private network IP, range: 192.168.0.0 ~ 192.168.255.255
	config.vm.network "private_network", ip: "192.168.33.10"
	# config.vm.network "private_network", type: "dhcp"
	config.vm.network "public_network"		# Network bridge

    # Shared folder between (host,guest)
    config.vm.synced_folder "../data", "/vagrant_data"

    # provider configuration
    # config.vm.provision :shell, path: "bootstrap.sh"
    config.vm.provider "virtualbox" do |vb|
        #vb.gui = true            # enable GUI or not
        vb.cpus = "2"            # Number of CPU
        vb.memory = "1024"        # Memory allocated, MB
    end

    # Used for build the environment before ready to use ^(1)
    # The following session will not be executed unless 
    # --provision is added
    # Use `vagrant provision`
    config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
    config.vm.provision "shell", inline: <<-SHELL
        apt-get update
        apt-get install -y apache2
    SHELL

(1) What is Provision 伺服器服務開通(Server provisioning)是指:以合適的系統、數據和軟體來準備一個伺服器,並使其可用於網絡操作的一系列動作。開通一個伺服器的典型任務是:從一個可用伺服器的池裡面選擇一個伺服器,載入相應的軟體(作業系統、設備驅動、中間件和應用程式),適當地對系統和軟體進行定製化和配置,從而為這個伺服器創建或改變一個引導映像(boot image),並隨後更改其參數,例如網際協議(IP)地址、網際協議網關,以找到相關的網絡和存儲資源(某些時候被獨立分出為資源開通)來審計該系統。通過審計此系統,確保只有有限的漏洞並遵從開放式漏洞和評價語言(Open Vulnerability and Assessment Language,簡稱OVAL),保證承諾,或安裝補丁。在這些動作後,重啟系統並載入新軟體。這使得系統做好了運營的準備。

i.e. provisioning 是機器「第一次」被建立起來時或要加入服務前必須進行的工作

PreviousBasic CommandsNextExample

Last updated 6 years ago

Was this helpful?