1 - Vagrant on Windows
1. Overview
|
Important
|
This documentation describes the installation of the required tools for ansible-oracle on a Windows based hostsystem. |
-
Requirements
-
Intel/AMD x86 CPU is mandatory
no support for Mac with M1 -
16 GB RAM
-
150 GB free Disk space
The free space is needed in your home directory in Windows. -
Admin privileges on Host machine
-
Hyper-V disabled
-
no WSL/WSL2 for installation
While you may try it, the documentation states that Hyper-V should be completely disabled and that no WSL/WSL2 is used.
-
|
Warning
|
There are many issues when Hyper-V is active on the host machine. Please switch Hyper-V off completely, before starting the boxes with Vagrant. If you do find a really good working solution with Vagrant + VirtualBox and Hyper-V, feedback is welcome. |
2. Installation
2.1. Disable Hyper-V in Windows
|
Warning
|
There are numerous problems with Vagrant & VirtualBox when Hyper-V is enabled. It is therefore recommended to disable it for ansible-oracle.
|
|
Important
|
All commands require a cmd.exe with admin rights. |
bcdedit
The output should contain a line with hypervisorlaunchtype.
If the line is not shown or Off, Hyper-V is completely disabled.
# bcdedit Windows-Start-Manager --------------------- ... Windows-Startladeprogramm ------------------------- ... hypervisorlaunchtype Off
If it is Auto or On
bcdedit /set {current} hypervisorlaunchtype off
shutdown -r -t 0
2.2. Chocolatey
|
Important
|
The installation of Chocolatey is not mandatory for ansible-oracle.All tools could be installed manually. Please ensure, that they are all executable from git+bash.It is highly recommended to use Chocolatey with ansible-oracle.
|
|
Important
|
See the Homepage of chocolatey for more details. |
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
2.3. git+bash, VirutalBox and Vagrant
choco install git vagrant virtualbox
2.4. ConEmu - Handy Windows Terminal
|
Important
|
This step is optional. |
This is a really good alternative terminal to cmd.exe for windows.
It is not recommended for ansible-oracle but you should give it a try and enjoy it - especially when VSCode is not used.
choco install conemu
2.5. Visual Studio Code
|
Important
|
This step is optional. You should use VSCode - especially when Advanced or Expert setups are planned for a later time. |
choco install vscode.install
3. Configuration
3.1. SSH-Setup
|
Warning
|
The example expects the private key at the default location. |
|
Important
|
Create a custom key and place the public key in same directory as the Vagrantfile.
Do not use the created keys from Vagrant. You should always use the ssh-agent to connect to all machines.
|
|
Important
|
All commands are executed in git+bash on the Host machine - not inside a VM!
|
ssh-keygen
ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/User/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/User/.ssh/id_rsa Your public key has been saved in /c/Users/User/.ssh/id_rsa.pub The key fingerprint is: SHA256:Xq9EGKMUEXFkxeli4NilfvwEkOAmvkV1PiRteA+NQRQ ubuntu@ansible-oracle-bastion
|
Important
|
Enable Agent Forwarding for all SSH-Sessions. This is mandatory for Visual Studio Code. |
code ~/.ssh/config Host * ForwardAgent yes
eval $(ssh-agent)
eval $(ssh-agent) Agent pid 16840
ssh-add ~/.ssh/id_rsa
$ ssh-add ~/.ssh/id_rsa Identity added: /c/Users/User/.ssh/id_rsa (User@unknown)
ssh-add -l
ssh-add -l 2048 SHA256:EsVIFzfCLUDTO2cMTf4q4qt2Eu0w1pA2sdcXxh9jyBs User@unknown (RSA)
3.2. Vagrant SSH-Setup
|
Important
|
The Vagrantfile has a provisioner script block which copy a stored id_rsa.pub into authorized_keys on the target machine.
|
The exact command to copy the key is shown during the deployment description.
3.3. Vagrant Plugins
The following modules are used by the tutorial examples.
-
install* vagrant-disksize
This is an experimental plugin which is needed to resize the 1. disk of a vagrant box.
vagrant plugin install vagrant-disksize
4. See also
-
Basic command and setup of Vagrant: Preparation for beginner
2 - Vagrant Basics
What is vagrant?
Vagrant is a tool that makes it EASIER and FASTER to setup virtual machines. Vagrant Boxes are pre-built base images (e.g. Oracle Linux) that can be imported into Vagrant as a starting point. For our use-case, we will use Vagrant together with Virtualbox and Oracle Linux
Installation
- Download and install Vagrant
- Download and install Oracle Virtualbox
Let’s start
Using Tim Halls’s guide, let’s play https://oracle-base.com/articles/vm/vagrant-a-beginners-guide
- hmm, cannot download that first OL box, let’s see the oracle doc https://yum.oracle.com/boxes/
- Note also that the default provider for vagrant has changed to libvirt (was virtualbox), so we will need to add “–provider virtualbox” to our vagrant add commands
Download Vagrant boxes
- Instead of downloading a large DVD image, we can download a small vagrant box.
- We can manually download a new box using the vagrant box add command.
- We only need to do this once for each vagrant box (e.g. one time for Oracle Linux 7 and one time for Oracle Linux 8).
- This download process would also happen automatically if required, when you reference a new box in a Vagrantfile
In a DOS command prompt…
vagrant box add --provider virtualbox https://oracle.github.io/vagrant-projects/boxes/oraclelinux/7.json
vagrant box add --provider virtualbox https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8.json
Some vagrant addons
- allows us to resize disks (optional)
In a DOS command prompt…
vagrant plugin install vagrant-disksize
- ensure the virtualbox guest additions is updated, required to ensure that the guest additions are automatically updated for all new vagrant boxes
In a DOS command prompt…
vagrant plugin install vagrant-vbguest
- Automatically update the /etc/hosts
In a DOS command prompt…
vagrant plugin install vagrant-hostsupdater
Create the initial vagrantfile
To create the virtual machine, we first of all create a new directory, change to it and create the initial “vagrantfile”
In a DOS command prompt…
mkdir D:\vagrant\vol7db19
cd /D D:\vagrant\vol7db19
vagrant init
Start the VM
edit the vagrantfile (see Tim Hall’s website above) and when ready with our configuration, we can install, create and start the VM with the following command…
In a DOS command prompt…
vagrant up
Changing the vagrantfile
if you change the vagrantfile, destroy and recreate your virtual machine
In a DOS command prompt…
vagrant destroy -f
vagrant up
accessing the VM
- use the command “vagrant ssh” to access the VM per shh in your DOS command prompt
- or connect with ssh to 127.0.0.1, port 2222 with your favourite tool
Removing Vagrant boxes
- We can remove any old boxes we are no longer using, with the vagrant box remove command.
- These boxes will be automatically downloaded again if required.
- It is best not to remove them, if still used regularly, as it takes a few minutes to download them
In a DOS command prompt…
vagrant box remove oraclelinux/7
vagrant box remove oraclelinux/8