Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* A vagrant project with an ubuntu box with the tools needed to do DevOps

# tools included
* Docker
* Terraform
* Packer
* AWS CLI
* Ansible
28 changes: 17 additions & 11 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
Vagrant.configure(2) do |config|
config.vm.define "devops-box" do |devbox|
devbox.vm.box = "ubuntu/bionic64"
#devbox.vm.network "private_network", ip: "192.168.199.9"
#devbox.vm.hostname = "devops-box"
devbox.vm.provision "shell", path: "scripts/install.sh"
devbox.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
end
Vagrant.configure("2") do |config|
# Remove the first "600" line
# config.vm.boot_timeout = 600 # Remove or comment out

config.vm.define "devops-box" do |devbox|
#devbox.vm.box = "ubuntu/bionic64"
devbox.vm.box = "ubuntu/focal64"
devbox.vm.provision "shell", path: "scripts/install.sh"
devbox.vm.provider "virtualbox" do |v|
#v.gui = true
v.memory = 4096
v.cpus = 2
end
end

# Keep the final large timeout, e.g., 1440 seconds
config.vm.boot_timeout = 1440
end
74 changes: 74 additions & 0 deletions error_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Stderr: VBoxManage.exe: error: Call to WHvSetupPartition failed

Note about VirtualBox 6.1.0. This topic has the name it has because that was how most users encountered the problem of VT-x/AMD-v hardware accelerated virtualization not being available.
If the topic had been called "VT-x not available error" then newbies may not have understood the relevance. However VirtualBox 6.1.0 now requires VT-x/AMD-v to be available (or Windows NEM,
but we'll leave that for now) for all VMs, whether 32bit, 64bit, single or multiple vCPU and so on. The original text remains below, the "bittedness" stuff is now less relevant, but the
underlying problem and solutions have not changed.

VirtualBox requires hardware support for virtualization (Intel VT-x or AMD-v) in order to run certain categories of VM. This includes all 64bit VMs, and all VMs which use >1 CPU core. OS X hosts
require VT-x/AMD-v for every VM. Starting with VirtualBox 6.1.0 the latter is now true for all other hosts. The developers clearly feel that supporting older machines that don't have this hardware
feature is no longer justified commercially.

To ensure that you can still run VMs in those categories, run through the following checklist :-

Note your exact CPU model or part number, then go online and check its capabilities. The CPU must be 64bit and support either Intel or AMD virtualization technologies: VT-x or AMD-v.
.
You usually need to enable VT-x/AMD-v in the host PC BIOS. You need to check with your PC manual or support forum to find out how to boot into the BIOS screen. This is probably not something we
here at the VirtualBox forums can help you with. Once you get there you need to look for something buried in a menu, perhaps in the security category. The option may be called something like
"Enable Virtualization Technology", "Enable SVM Mode" (AMD CPUs), "Enable Vanderpool Technology" (Intel), or perhaps "Secure Virtual Mode". If you see "Virtual Directed I/O" (VT-d/AMD-Vi) then
that is a different thing. If you can find the latter option but can't find the former, and it's a recent PC (post 2016) then it's likely that VT-x/AMD-v is enabled by default in your BIOS, so
go to step 3! Remember to cycle power on your host PC after making and saving the BIOS changes - in this case a full restart from power off is required, just rebooting or resuming from a
hibernated state may not do the job.
.
If (1) and (2) are already taken care of, then make sure that no other host apps are already using VT-x/AMD-v. The usual culprits are system level debuggers, other VM platforms, and some resident
anti-virus applications. This has become a particular issue with 64bit Windows desktop and server hosts - especially Win2k12 and Win10, as these may enable Microsoft's Hyper-v VM platform by
default: this grabs ownership of VT-x and won't play nice with VirtualBox. Note: see the third post below for other Win10 functions that have this effect.
.
When creating a VM, make sure you choose the 64-bit version of the guest OS template in <VM Settings> | General | Basic | Version, e.g. choose "Ubuntu (64 bit)" and not
"Ubuntu" or "Ubuntu (32bit)". This has become more important since VirtualBox 4.3.x, because choosing the correct template also allows other modern processor features to be visible to the
guest - it's not just about 64bit capability any more.

Additional Notes for Windows Hosts

1.- To check the status of Hyper-v in Windows 10, <right click start> | Run | OptionalFeatures.exe, and look for the "Hyper-V" option. The box should be empty, not checked or shaded. If you want
to be absolutely sure that Hyper-v is gone then open an administrator command console and type "bcdedit /set hypervisorlaunchtype off". Make sure to fully power down and reboot the host after
changing the Hyper-v setting.

2.- On some Windows hosts with an EFI BIOS, DeviceGuard or CredentialGuard may be active by default, and interferes with OS level virtualization apps in the same way that Hyper-v does. These
features
need to be disabled. On Pro versions of Windows you can do this using gpedit.msc (set Local Computer Policy > Computer Configuration > Administrative Templates > System > Device Guard >
Turn on Virtualization Based Security to Disabled. CredentialGuard is a subset of DeviceGuard, so disabling the former should be enough. If you cannot use gpedit for some reason then the
equivalent registry hack is to find the key HKLM|SYSTEM|CurrentControlSet|Control|DeviceGuard|EnableVirtualizationBasedSecurity|Enabled and set it to 0.

3.- On Win10 hosts, check Windows Defender > Device Security > Core Isolation Details and make sure settings in this panel are turned off, reboot the host from power down if you needed to
make changes.
"Core isolation [includes] security features available on your device that use virtualization-based security"
...which is why they can interfere with VirtualBox.



The following information is courtesy of user "Socratis". He has made a list of new features that Microsoft have added to Windows 10 which implicitly enable Hyper-V and therefore prevent VirtualBox from using VT-x directly. In an ideal world these should all be disabled, and please understand that Microsoft seems to be adding to this list all the time.

Socratis wrote:
Here's the list that I have so far:

Application Guard
Credential Guard (see https://www.microsoft.com/en-us/downloa ... x?id=53337)
Device Guard (see https://www.microsoft.com/en-us/downloa ... x?id=53337)
<any> * Guard
Containers
Hyper-V
Virtual Machine Platform
Windows Hypervisor Platform
Windows Sandbox
Windows Server Containers
Windows Subsystem for Linux 2 (WSL2) (WSL1 does not enable Hyper-V)

If that doesn't work, enter the following command:

bcdedit /set hypervisorlaunchtype off

followed by a cold boot, i.e. shut down the computer, pull the power plug for 10 seconds, reboot.

If Hyper-V cannot be disabled, e.g. due to company policy, then VirtualBox v6.x has a new ability to run via the Windows Hypervisor Platform, however Windows 10 (1809) or later is required,
the feature still has bugs (as of VirtualBox 6.0.8), and it currently causes a significant drop in VM performance.
265 changes: 265 additions & 0 deletions info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
#bcdedit /set hypervisorlaunchtype off
#bcdedit /set hypervisorlaunchtype on
#bcdedit /set hypervisorlaunchtype auto

#Vagrant up - VBoxManage.exe error: VT-x is not available

Stop hyper-v service running by default in Windows 8/10, since it blocks all other calls to VT hardware.

Additional explanation here: https://social.technet.microsoft.com/Forums/windows/en-US/118561b9-7155-46e3-a874-6a38b35c67fd/hyperv-disables-vtx-for-other-hypervisors?forum=w8itprogeneral

Also as you have mentioned, if not already enabled, turn on Intel VT virtualization in BIOS settings and restart the machine.

To turn Hypervisor off, run this from Command Prompt (Admin) (Windows+X):

bcdedit /set hypervisorlaunchtype off
and reboot your computer. To turn it back on again, run:

bcdedit /set hypervisorlaunchtype on
If you receive "The integer data is not valid as specified", try:

bcdedit /set hypervisorlaunchtype auto

#In Windows Features eliminate windows Sandbox so you can use both vagrant and docker toguether

vagrant up
vagrant ssh-config
-------------------------------
Host devops-box
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile E:/IdeaProjects/devops-box/.vagrant/machines/devops-box/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
-------------------------------

vagrant ssh devops-box

ansible --version
docker -v
aws --version
packer -v
terraform version

#rm -rf .vagrant/

vagrant upload scripts/packer.sh
vagrant upload scripts/terraform.sh
vagrant upload scripts/terraform_version.sh
vagrant upload terraform-test/main.tf
vagrant upload terraform-test/resource.tf
vagrant upload terraform-test/terraform.tfvars

vagrant global-status
vagrant plugin install vagrant-scp
vagrant destroy 1a2b3c4d
vagrant destroy devops-box
vagrant destroy -f devops-box
vagrant box list
vagrant status devops-box
vagrant halt devops-box
vagrant suspend devops-box
vagrant up devops-box

vagrant scp devops-box:/home/vagrant/terraform_version.sh "E:\IdeaProjects\devops-box\scripts"

vagrant scp devops-box:/home/vagrant/terraform-test/main.tf "E:\IdeaProjects\devops-box\terraform-test"
vagrant scp devops-box:/home/vagrant/terraform-test/resource.tf "E:\IdeaProjects\devops-box\terraform-test"
vagrant scp devops-box:/home/vagrant/terraform-test/terraform.tfvars "E:\IdeaProjects\devops-box\terraform-test"
vagrant scp devops-box:/home/vagrant/terraform-test/main.tf /e/IdeaProjects/devops-box/terraform-test/main.tf
vagrant scp devops-box:/home/vagrant/terraform-test/resource.tf /e/IdeaProjects/devops-box/terraform-test/resource.tf
vagrant scp devops-box:/home/vagrant/terraform-test/terraform.tfvars /e/IdeaProjects/devops-box/terraform-test/terraform.tfvars
vagrant scp terraform-test/main.tf devops-box:/home/vagrant/terraform-test/main.tf
vagrant scp terraform-test/resource.tf devops-box:/home/vagrant/terraform-test/resource.tf
vagrant scp terraform-test/terraform.tfvars devops-box:/home/vagrant/terraform-test/terraform.tfvars
vagrant scp terraform devops-box:/home/vagrant
scp -P 2222 alien4cloud-premium-dist-3.4.0-dist.tar.gz vagrant@127.0.0.1:.

vagrant box update
vagrant provision
vagrant up --provision devops-box
vagrant reload
vagrant reload --provision devops-box
vagrant reload --provision
vagrant --debug ssh

vagrant plugin repair
vagrant plugin expunge --reinstall
vagrant plugin update


mkdir terraform-test
cd terraform-test
vi main.tf

vagrant@ubuntu-bionic:~$ cat main.tf
variable "myvar" {
type = "string"
default = "hello terraform"
}

variable "mymap" {
type = map(string)
default = {
mykey = "my value"
}
}

variable "mylist" {
type = list
default = [1, 2, 3]
}


terraform version

terraform console
var.myvar
or
"${var.myvar}"

var.mymap
or
"${var.mymap}"

var.mymap["mykey"]
or
"${var.mymap["mykey"]}"

var.mylist
or
"${var.mylist}"

var.mylist[0]
or
"${var.mylist[0]}"

element(var.mylist, 1)
element(var.mylist, 0)
slice(var.mylist, 0, 2)

exit

aws configure

#export TF_LOG=TRACE
#export TF_LOG=DEBUG
#export TF_LOG=INFO

#export VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

https://www.terraform.io/docs/extend/writing-custom-providers.html

mkdir -p .terraform.d/plugins/linux_amd64
cd .terraform.d/plugins/linux_amd64
wget -q https://releases.hashicorp.com/terraform-provider-google/3.25.0/terraform-provider-google_3.25.0_linux_amd64.zip
unzip -o terraform-provider-google_3.25.0_linux_amd64.zip
rm -f terraform-provider-google_3.25.0_linux_amd64.zip

mkdir -p .terraform.d/plugins/linux_amd64
cd .terraform.d/plugins/linux_amd64
wget -q https://releases.hashicorp.com/terraform-provider-azure/0.1.1/terraform-provider-azure_0.1.1_linux_amd64.zip
unzip -o terraform-provider-azure_0.1.1_linux_amd64.zip
rm -f terraform-provider-azure_0.1.1_linux_amd64.zip

mkdir -p .terraform.d/plugins/linux_amd64
cd .terraform.d/plugins/linux_amd64
#wget -q https://releases.hashicorp.com/terraform-provider-aws/2.66.0/terraform-provider-aws_2.66.0_linux_amd64.zip
wget -q https://releases.hashicorp.com/terraform-provider-aws/2.69.0/terraform-provider-aws_2.69.0_linux_amd64.zip
#unzip -o terraform-provider-aws_2.66.0_linux_amd64.zip
unzip -o terraform-provider-aws_2.69.0_linux_amd64.zip
#rm -f terraform-provider-aws_2.66.0_linux_amd64.zip
rm -f terraform-provider-aws_2.69.0_linux_amd64.zip

cd terraform-test
terraform init
terraform console
terraform providers

var.AWS_REGION
var.AMIS[var.AWS_REGION]

http://www.cloudping.info/
https://cloud-images.ubuntu.com/locator/ec2/

terraform plan
terraform apply
terraform show
terraform destroy

terraform plan -out out.terraform
terraform apply out.terraform
terraform show
terraform destroy

sudo apt-get install ntpdate; ntpdate ntp.ubuntu.com

ssh-keygen -f mykey
ssh -i "mykey" ubuntu@18.197.163.93
ssh -i "mykey" ubuntu@ec2-18-197-163-93.eu-central-1.compute.amazonaws.com
ssh -i mykey -l ubuntu ec2-18-197-163-93.eu-central-1.compute.amazonaws.com
ssh -i mykey -l ubuntu -o "StrictHostKeyChecking no" ec2-18-197-163-93.eu-central-1.compute.amazonaws.com
ssh -i mykey -l ubuntu -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ec2-18-197-163-93.eu-central-1.compute.amazonaws.com

#What you do is fix the networking on the server and add some extra time for the boot:
start the VM, log in to the server via GUI (username: vagrant, password: vagrant) and run the following commands

sudo apt install -y ifupdown
sudo vi /etc/network/interfaces.d/eth0

# add this
auto eth0
iface eth0 inet dhcp

sudo /etc/init.d/networking restart

$ sudo ifdown eth0
$ sudo ifup eth0
then add the following to the file /etc/rc.local

ifdown eth0
ifup eth0
on the host, add the following to the Vagrantfile


config.vm.boot_timeout = 600

#Error vagrant ssh fails with VirtualBox
1.- in the VagrantFile, add the gui mode : config.vm.boot_mode = :gui
2.- run vagrant up
3.- in the gui, log with the user "vagrant" (password = "vagrant")
4.- in the gui, run sudo /etc/init.d/networking restart, in /etc/network/interfaces file, you must now have a section with #VAGRANT-BEGIN [...]#VAGRANT-END
5.- run vagrant reload on the physical machine


unset SSH_AUTH_SOCK
unset SSH_AGENT_PID



config.vm.boot_timeout = 600
vagrant reload --provision
vagrant ssh-config

ssh -i "C:\Program Files (x86)\Vagrant\bin\insecure_private_keys\vagrant.key.rsa" -p 2222 vagrant@127.0.0.1

vagrant ssh --debug

vagrant ssh-config
ssh-keygen -R [127.0.0.1]:2222
vagrant ssh


ssh -vvv -i "C:\Program Files (x86)\Vagrant\bin\insecure_private_keys\vagrant.key.rsa" -p 2222 vagrant@127.0.0.1
ssh -vvv -i "C:\Program Files (x86)\Vagrant\bin\insecure_private_keys\vagrant.key.ed25519" -p 2222 vagrant@127.0.0.1
vagrant ssh-config

vagrant destroy -f
vagrant box remove ubuntu/bionic64
vagrant box add ubuntu/bionic64
vagrant up

Loading