Vagrant : インストール2023/04/27 |
VirtualBox 等の仮想化ソフトウェアのラッパーツール Vagrant をインストールします。
主要な仮想化ソフトウェアには概ね対応していますが、当例では
Libvirt インストール済みを前提とします。
|
|
[1] | Vagrant をインストールしておきます。 |
root@dlp:~# apt -y install vagrant-libvirt
|
[2] | Vagrant の基本操作です。任意の一般ユーザーで利用可能です。 |
# 仮想マシンイメージをダウンロードして追加 # ダウンロード可能な Box は公式サイト参照 # ⇒ https://app.vagrantup.com/boxes/search ubuntu@dlp:~$ vagrant box add generic/ubuntu2204 --provider libvirt ==> box: Loading metadata for box 'generic/ubuntu2204' box: URL: https://vagrantcloud.com/generic/ubuntu2204 ==> box: Adding box 'generic/ubuntu2204' (v4.2.16) for provider: libvirt box: Downloading: https://vagrantcloud.com/generic/boxes/ubuntu2204/versions/4.2.16/providers/libvirt.box box: Calculating and comparing box checksum... ==> box: Successfully added box 'generic/ubuntu2204' (v4.2.16) for 'libvirt'! # 初期化 (カレントパスに Vagrantfile が作成される) ubuntu@dlp:~$ vagrant init generic/ubuntu2204 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. # 仮想マシン起動 ubuntu@dlp:~$ vagrant up Bringing machine 'default' up with 'libvirt' provider... ==> default: Checking if box 'generic/ubuntu2204' version '4.2.16' is up to date... ==> default: Uploading base box image as volume into Libvirt storage... ==> default: Creating image (snapshot of base box volume). ==> default: Creating domain with the following settings... ==> default: -- Name: ubuntu_default ==> default: -- Description: Source: /home/ubuntu/Vagrantfile ==> default: -- Domain type: kvm ==> default: -- Cpus: 2 ==> default: -- Feature: acpi ==> default: -- Feature: apic ==> default: -- Feature: pae ==> default: -- Clock offset: utc ==> default: -- Memory: 2048M ==> default: -- Base box: generic/ubuntu2204 ==> default: -- Storage pool: default ==> default: -- Image(vda): /var/lib/libvirt/images/ubuntu_default.img, virtio, 128G ==> default: -- Disk driver opts: cache='default' ==> default: -- Graphics Type: vnc ==> default: -- Video Type: cirrus ==> default: -- Video VRAM: 256 ==> default: -- Video 3D accel: false ==> default: -- Keymap: en-us ==> default: -- TPM Backend: passthrough ==> default: -- INPUT: type=mouse, bus=ps2 ==> default: Creating shared folders metadata... ==> default: Starting domain. ==> default: Domain launching with graphics connection settings... ==> default: -- Graphics Port: 5900 ==> default: -- Graphics IP: 127.0.0.1 ==> default: -- Graphics Password: Not defined ==> default: -- Graphics Websocket: 5700 ==> default: Waiting for domain to get an IP address... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 192.168.121.78:22 default: SSH username: vagrant default: SSH auth method: private key default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! # 仮想マシンの状態 ubuntu@dlp:~$ vagrant status Current machine states: default running (libvirt) The Libvirt domain is running. To stop this machine, you can run `vagrant halt`. To destroy the machine, you can run `vagrant destroy`. # 仮想マシンへ SSH で接続 ubuntu@dlp:~$ vagrant ssh vagrant@ubuntu2204:~$ uname -a Linux ubuntu2204.localdomain 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux vagrant@ubuntu2204:~$ exit # 仮想マシン停止 ubuntu@dlp:~$ vagrant halt ==> default: Attempting graceful shutdown of VM... # 例として CPU 数とメモリー容量を変更 # 52 行目から以下のようにコメント解除して値を変更 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 = "4096" vb.cpus = 2 end |
Sponsored Link |
|