first timer here but have been lurking for years:) usually i can find the answer to my troubles here but nto today:)
I have the following vagrant file:
Vagrant.configure(2) do |config|
config.vm.define :webserver do |webserver|
webserver.vm.box = "vagrant-centos-base.box"
webserver.vm.box_url = "http://127.0.0.1/vagrant-centos-base.box"
#webserver.memory = "512"
webserver.vm.network "private_network", ip: "10.2.0.10"
#webserver.vm.network :forwarded_port, guest: 80, host 80
webserver.vm.network "forwarded_port", guest: "443", host "443"# , protocol: "tcp"
webserver.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
webserver.vm.provision "shell", inline: <<-SHELL
sudo hostname webserver
SHELL
#webserver.vm.provision "ansible" do |ansible|
# ansible.playbook="playbook.yml"
#end
end
config.vm.define :appserver do |appserver|
appserver.vm.box = "vagrant-centos-base.box"
appserver.vm.box_url = "http://127.0.0.1/vagrant-centos-base.box"
#appserver.memory = "1024"
appserver.vm.network "private_network", ip: "10.2.0.11"
appserver.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
#vb.customize ["createhd", "--filename", "disk.vmdk", "--size", "1024"]
#vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "disk.vmdk"]
#vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "1", "--type", "hdd", "--medium", "machine1_disk0.vdi"]
end
appserver.vm.provision "shell", inline: <<-SHELL
sudo hostname appserver
SHELL
end
end
when i try to issue vagrant up i get the following error:
syntax error, unexpected ',', expecting keyword_end ...ort", guest:
"443", host "443", protocol: "tcp" ... ^
if i comment out the protocol part i get a bit of a different one
then: : syntax error, unexpected tSTRING_BEG, expecting keyword_do or
'{' or '(' ...ded_port", guest: "443", host "443"# , protocol: "tcp"
... ^
I am lost at this point. I have tried all types of configs but non allow me to start the vm with port forwarding.
thank you in advance!
In the 'Options' section of the Vagrant Forwarded Ports documentation, it says that guest and host are both int type. Try removing the quotation marks (") from around those variables.
My understanding is that vagrant will not automatically convert from string to int (for example).
i found the issue, I missed the : after defining the host portion of the port forwarding statement. It is all working now. Thank You!
Related
When I run vagrant up on my Centos6, it shows this error:
==> w3package_v2: Running provisioner: ansible_local...
w3package_v2: Installing Ansible...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
sudo rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm >-E %dist | sed -n 's/.*el\
([0-9]\).*/\1/p'`.noarch.rpm
Stdout from the command:
Stderr from the command:
curl: (22) The requested URL returned error: 403 Forbidden
error: skipping https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Below is Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
APP_NAME = "w3package_v2"
VM_NAME = "w3package_v2"
GUEST_IP = "192.168.33.59"
# [note]
# * for VirtualBox users:
# vagrant-vbguest plugin required.
# Run `vagrant plugin install vagrant-vbguest`.
# * for Windows10 + Hyper-V users:
# Enable SMB 1.0 (for Windows 10 + Hyper-V users)
if !Object.const_defined?('VagrantVbguest') || !Vagrant.has_plugin?('vagrant-vbguest')
puts "ERROR: vagrant-vbguest plugin is required. Run `vagrant plugin install vagrant-vbguest`."
abort
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define VM_NAME
config.vm.box = "bento/centos-6"
config.vm.boot_timeout = 3600
config.vm.network :private_network, ip: GUEST_IP
config.vm.network :public_network, bridge: 'en0: Wi-Fi (AirPort)'
if OS.windows?
config.vm.synced_folder ((File.expand_path(File.dirname(__FILE__) + "/../../../..")).gsub("/","\\")), "/var/www/" + APP_NAME + "/current", owner: "vagrant", type: "virtualbox", automount: true, SharedFoldersEnableSymlinksCreate: true
else
config.vm.synced_folder "../../../..", "/var/www/" + APP_NAME + "/current", id: "vagrant", nfs: true
end
config.ssh.insert_key = false
config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key"
config.vm.provider :virtualbox do |vb|
vb.name = VM_NAME
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "100"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", :id, "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled", 0]
if OS.windows?
vb.customize ["sharedfolder", "add", :id, "--name", VM_NAME, "--hostpath", (("//?/" + File.expand_path(File.dirname(__FILE__) + "/../../../..")).gsub("/","\\"))]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/" + VM_NAME, "1"]
config.vm.provision "shell", path: "../../configuration/vagrant-vbmount.sh", args: VM_NAME
end
end
config.vm.provider :hyperv do |h, override|
h.enable_virtualization_extensions = true
h.linked_clone = true
override.vm.synced_folder ((File.expand_path(File.dirname(__FILE__) + "/../../../..")).gsub("/","\\")), "/var/www/" + APP_NAME + "/current", type: "smb", automount: true, SharedFoldersEnableSymlinksCreate: true
end
config.vm.provision "ansible_local" do |ansible|
ansible.limit = "all"
ansible.compatibility_mode = "2.0"
ansible.playbook = "/var/www/" + APP_NAME + "/current/tools/provisioning/configuration/vagrant-local.yml"
ansible.verbose = "v"
end
end
## ref https://qiita.com/dd511805/items/8cb7e524e0d790c24af1
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
end
And this is my main.yml file:
- name: check dir /var/www
shell: '[ -e /var/www ]; echo $?'
register: result
- name: mkdir /var/www
command: mkdir /var/www
when: result.stdout != '0'
- name: change locale
shell: 'cp /usr/share/zoneinfo/Japan /etc/localtime'
- name: install python-selinux
yum: pkg=libselinux-python state=latest
- name: disable selinux
selinux: state=disabled
- name: install epel-repo
yum: pkg=epel-release state=latest
- name: fix CentOS-Base.repo
template: src=CentOS-Base.repo dest=/etc/yum.repos.d/CentOS-Base.repo
- name: update yum
yum: name=* state=latest
How could I fix that?
I am using vagrant and ubuntu16.04 .
When i ran vagrant up i got the error as
A customization command failed:
["storageattach", :id, "--storagectl", "IDE Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "server.vdi"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["storageattach", "538c4e03-f4ea-4adf-af6e-02d303d56f13", "--storagectl", "IDE Controller", "--port", "1", "--device", "0", "--type", "hdd", "--medium", "server.vdi"]
Stderr: VBoxManage: error: Could not find a controller named 'IDE Controller'
>
Please fix this customization and try again.
There seems to be conflict between the id generated by script and virtualbox machines one.
My Vagrant file is
# -*- mode: ruby -*-
# vi: set ft=ruby :
server_disk='server.vdi'
desktop_disk='desktop.vdi'
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.vm.define "classroom" do |s|
s.vbguest.auto_update = false
s.vm.network "private_network", ip: "192.168.33.254"
s.vm.synced_folder ".", "/vagrant", disabled: true
#s.vm.synced_folder "../repos", "/repos", owner: "root", group: "root"
s.vm.synced_folder "scripts/classroom", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
s.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/classroom.sh
/usr/local/scripts/classroom.sh
SHELL
end
config.vm.define "server" do |a|
a.vbguest.auto_update = false
a.vm.provider "virtualbox" do |v|
unless File.exist?(server_disk)
v.customize ['createhd', '--filename', server_disk, '--size', 20 * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', server_disk]
end
a.vm.network "private_network", ip: "192.168.33.11"
a.vm.synced_folder ".", "/vagrant", disabled: true
a.vm.synced_folder "scripts/server", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
a.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/server.sh
/usr/local/scripts/server.sh
SHELL
end
config.vm.define "desktop" do |b|
b.vbguest.auto_update = false
b.vm.provider "virtualbox" do |v|
unless File.exist?(desktop_disk)
v.customize ['createhd', '--filename', desktop_disk, '--size', 20 * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', desktop_disk]
end
b.vm.network "private_network", ip: "192.168.33.10"
b.vm.synced_folder ".", "/vagrant", disabled: true
b.vm.synced_folder "scripts/desktop", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
b.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/desktop.sh
/usr/local/scripts/desktop.sh
SHELL
end
end
VBoxManage list vms
gives output as
"ubuntu-server" {bc38335e-ddf7-48a1-b0be-3df2495b91df}
On changing the IDECONTROLLER to IDE the issue was fixed
I am trying to setup an RHCE lab on my machine. I've installed vagrant version Vagrant 2.1.4 and virtualbox 5 on ubuntu 16.04. I downloaded centos-7.0-x86_64.box from [https://computingforgeeks.com/how-to-addinstall-and-run-centos-7-vagrant-box-to-virtualbox-using-vagrant/][1]
I installed vagrant plugins vagrant plugin vagrant-vbguest && sahara
Here is my vagrant script
# -*- mode: ruby -*-
# vi: set ft=ruby :
server_disk='server.vdi'
desktop_disk='desktop.vdi'
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.vm.define "classroom" do |s|
s.vbguest.auto_update = false
s.vm.network "private_network", ip: "192.168.33.254"
s.vm.synced_folder ".", "/vagrant", disabled: true
#s.vm.synced_folder "../repos", "/repos", owner: "root", group: "root"
s.vm.synced_folder "scripts/classroom", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
s.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/classroom.sh
/usr/local/scripts/classroom.sh
SHELL
end
config.vm.define "server" do |a|
a.vbguest.auto_update = false
a.vm.provider "virtualbox" do |v|
unless File.exist?(server_disk)
v.customize ['createhd', '--filename', server_disk, '--size', 20 * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', server_disk]
end
a.vm.network "private_network", ip: "192.168.33.11"
a.vm.synced_folder ".", "/vagrant", disabled: true
a.vm.synced_folder "scripts/server", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
a.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/server.sh
/usr/local/scripts/server.sh
SHELL
end
config.vm.define "desktop" do |b|
b.vbguest.auto_update = false
b.vm.provider "virtualbox" do |v|
unless File.exist?(desktop_disk)
v.customize ['createhd', '--filename', desktop_disk, '--size', 20 * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', desktop_disk]
end
b.vm.network "private_network", ip: "192.168.33.10"
b.vm.synced_folder ".", "/vagrant", disabled: true
b.vm.synced_folder "scripts/desktop", "/usr/local/scripts", type: "rsync", owner: "root", group: "root"
b.vm.provision "shell", inline: <<-SHELL
chmod u+x /usr/local/scripts/desktop.sh
/usr/local/scripts/desktop.sh
SHELL
end
end
When I run sudo vagrant up
I get error
An error occurred in the underlying SSH library that Vagrant uses.
The error message is shown below. In many cases, errors from this
library are caused by ssh-agent issues. Try disabling your SSH
agent or removing some keys and try again.
If the problem persists, please report a bug to the net-ssh project.
timeout during server version negotiating
I am following this https://github.com/frezbo/lab .Please do help me.
Initially, I had 8 vagrant machines running and something went wrong. So I deleted the vms in ~/VirtualBox\ VMs folder and placed the backup .vmdk files in the same location.
Then I tried running vagrant up...
But I'm getting the following error
Bringing machine 'virtual-am1' up with 'virtualbox' provider...
==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
virtual-am1: Adapter 1: nat
virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--name", "virtual-am1"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]
Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp
>Please fix this customization and try again.
This is how my Vagrantfile looks like...
We had a custom Vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
config.vm.box = "centos653"
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
# config.vm.provision :shell, path: "bootstrap.sh"
nodes_config.each do |node|
node_name = node[0] # name of node
node_values = node[1] # content of node
config.vm.define node_name do |config|
# configures all forwarding ports in JSON array
ports = node_values['ports']
ports.each do |port|
config.vm.network :forwarded_port,
host: port[':host'],
guest: port[':guest'],
id: port[':id']
end
config.vm.synced_folder "/bits", "/vagrant/bits"
config.vm.synced_folder "../virtual", "/vagrant/virtual"
config.vm.hostname = node_values[':hostname']
#config.vm.network :private_network, ip: node_values[':ip']
config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_values[':node']]
vb.customize ["modifyvm", :id, "--cpus", 8]
end
end
end
end
This is how my nodes.json file looks like
{
"nodes": {
"virtual-am1": {
":node": "virtual-am1",
":ip": "192.168.1.50",
":hostname": "am1.onefederation.org",
"ports": [
{
":host": 2203,
":guest": 22,
":id": "ssh"
}
],
":memory": 1024
},
}
}
Please help!!!
I've had this error and you can use this fix:
Delete folder project in vagrant
rm -rf /home/protobox/VirtualBox VMs/project_folder
Go to project folder:
cd /var/www/project_folder
Then restart vagrant:
vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload
Finally you start vagrant
vagrant up
vagrant ssh
Or you can refer to here: http://getprotobox.com/docs/issues/vbox_rename
Good luck!
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.name = "web_vm"
v.customize ["modifyvm", :id, "--memory", "1024"]
#v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/web_vm", "1"]
end
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, host: 81, guest: 80, auto_correct: true
config.vm.network :forwarded_port, host: 6612, guest: 3306, auto_correct: true
config.vm.synced_folder "src/", "/var/www", owner: "vagrant", group: "vagrant", :mount_options => ["dmode=777,fmode=777"]
config.vm.provision :shell, path: "bootstrap.sh"
end
As you can see, The "src" folder is accessible in vagrant as "/var/www". However, there seem to be sync problems: I am trying to remove a folder which is shown empty where it is not when you cross-check with the Windows Explorer.
Any idea what is happening here?
I have the same issue, but it seemed to be resolved by increasing the max_user_watches - variable for inotify:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
My guess was that this had to to with the amount of files in the shared folder, and how vagrant has implemented the shared folder functionality.