Vagrant shared folder not working/synchronizing - linux

So I have a vagrant machine
m#m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'jasonc/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'jasonc/centos7' version '1.4.4' is up to date...
==> default: Setting the name of the VM: localuser_default_1635771672344_69157
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
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!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.2.6
default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
default: /vagrant => /home/m/Desktop/estudos/shellclass/localuser
When I try to create a test file on the folder:
m#m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ vagrant ssh
[vagrant#localhost ~]$ ls
[vagrant#localhost ~]$ cd vagrant
-bash: cd: vagrant: No such file or directory
[vagrant#localhost ~]$ cd ..
[vagrant#localhost home]$ ls
vagrant
[vagrant#localhost home]$ cd vagrant
[vagrant#localhost ~]$ touch teste
[vagrant#localhost ~]$ ls -l
total 0
-rw-rw-r-- 1 vagrant vagrant 0 Nov 1 09:02 teste
[vagrant#localhost ~]$ ls -l
total 0
-rw-rw-r-- 1 vagrant vagrant 0 Nov 1 09:02 teste
[vagrant#localhost ~]$ vagrant rsync-auto
-bash: vagrant: command not found
[vagrant#localhost ~]$ rsync-auto
-bash: rsync-auto: command not found
[vagrant#localhost ~]$
And when I try to access it from a normal linux terminal, I can't find the files:
m#m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ ls -l
ls: /lib/x86_64-linux-gnu/libselinux.so.1: no version information available (required by ls)
total 4
-rw-rw-r-- 1 m m 3020 nov 1 10:00 Vagrantfile
What is going on?
I had created this machine before and it was working properly until last friday. But now, for some reason, I just can't find the files anymore. When I open it on a graphical interface, I also see no file that I have created.

Without seeing your Vagrantfile it is difficult to answer your question. However after vagrant ssh you probably should do cd /vagrant in stead of cd vagrant (with forward slash).
Further more your guest additions are for a different version of virtualbox.
You could install the vbguest plugin to update: vagrant plugin install vagrant-vbguest
Finally virtualbox has been updated from version 6.1.26 to 6.1.28. This has also broken a number of configurations. See also Vagrant up failing for VirtualBox provider on Ubuntu

Related

Vagrant The machine is in the 'gurumeditation' state After Installing Android Emulator and Minikube

Hy folks, I'm using Vagrant box provisioned with Ansible and provider Oracle virtualbox, it was working fine for me.
But one day i installed Android Studio and it's Emulator and Minicube wit KVM.
Afterwards vagrant with virtual-box just stop working. Now whenever i run vagrant up i get below error.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/bionic64' version '20200416.0.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'gurumeditation' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
I need to run all of three on Ubuntu, How can i fix this?
1) Stop the VM
VBoxManage controlvm vm_123 poweroff
2) The check the settings.
VirtualBox will likely tell you there are some incompatible settings; correct those.
It could be the embedded virtualisation, or 32 vs 64 bits, or the amount of RAM for display or the virtual VGA display type, etc.
I had a gurumeditation issue with a fresh debian/buster64 and a reboot of my laptop fixed it (Virtualbox was only tellig me that the state was invalid in the log).
Some time lost for nothing. If ever it can help

vagrant up command SSL certificate problem

I'm on Windows 7. The Vagrant up command, it keep giving me this:
vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> defau
lt: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loadin
g metadata for box 'ubuntu/trusty64' default: URL: https://vagrantcloud.com/ubun
tu/trusty64 ==> default: Adding box 'ubuntu/trusty64' (v20190514.0.0) for provid
er: virtualbox default: Downloading: https://vagrantcloud.com/ubuntu/boxes/trust
y64/versions/20190514.0.0/providers/virtualbox.box default: Download redirected
to host: cloud-images.ubuntu.com default: An error occurred while downloading th
e remote file. The error message, if any, is reproduced below. Please fix this e
rror and try again.
SSL certificate problem: self signed certificate in certificate chain
I have searched the web for a solution but got nothing, also i'v try to reinstall the latest version of vagrant and virtual machine but got nothing
Any ideas?????
The problem i posted solved by pausing the antivirus on my pc.
after that i vagrant up again then i got the following:
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'unknown' state. Please verify everything is configured
properly and try again.
after so much trials oracle vm GUI gives me this message:
VT-x/AMD-V hardware acceleration is not available on your system. Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.
This usually solved from bios by enabling the VT-x graphics,but in my bios was no option like this so after going back to intel documentation it's turn out that my cpu doesn't support VT-x

Jenkins and Vagrant there is very strange situation

I have a last version Jenkis (run under the Tomcat) and the Vagrant and LXC container.
Tomcat running under jenkins user. I have next Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "arjenvrielink/xenial64-lxc"
config.vm.provider :lxc do |lxc|
lxc.backingstore = 'dir'
end
end
So, when I ran lxc container from bash by vagrant up everything was fine. And vagrant ssh worked. But if I run it via Jenkins job I get this
Started by user admin
[EnvInject] - Loading node environment variables.
Building in workspace /home/jenkins/workspaces/server
[server] $ /bin/bash /opt/tomcat/temp/jenkins204809790857124992.sh
Bringing machine 'default' up with 'lxc' provider...
==> default: Importing base box 'arjenvrielink/xenial64-lxc'...
==> default: Checking if box 'arjenvrielink/xenial64-lxc' is up to date...
==> default: Setting up mount entries for shared folders...
default: /vagrant => /home/jenkins/workspaces/server/vagrant
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 10.0.3.29:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
Build was aborted
Aborted by admin
Finished: ABORTED
Jenkins job contains only these commands
!#/bin/bash
cd vagrant
vagrant up
In process of investigation I found next different. Then I ran from bash the vagrant ssh-config out this:
Host default
HostName 10.0.3.212
User vagrant
Port 22
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/jenkins/workspaces/server/vagrant/.vagrant/machines/default/lxc/private_key
IdentitiesOnly yes
LogLevel FATAL
But then I ran from Jenkins job I got this
Host default
HostName 10.0.3.217
User vagrant
Port 22
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/jenkins/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
What did I do wrong?
EDIT:
arjenvrielink/xenial64-lxc is an official box
So I'm still pretty sure your problem is with the vagrant insecure key replacement mecanism but my solution won't help you.
Is arjenvrielink/xenial64-lxc a custom box ?
If so make sure to either let the insecure key in it so any new user(Jenkins included) will have access to the box because at fist up vagrant connect to the box using the insecure key then create a new one.
If you want to include your own key in the box make sure to add the following lines to your Vagrantfile:
Vagrant.configure("2") do |config|
config.ssh.private_key_path = File.expand_path("<path of the key relative to Vagrantfile>", __FILE__)
end
The caveat is you'll have to make the key available everywhere you vagrant environement will run.

Ubuntu vivid box not running with vagrant

I am using ubuntu vivid with Vagrant
https://vagrantcloud.com/ubuntu/boxes/vivid64
when i do vagrant up
i get this
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
service hostname start
Stdout from the command:
Stderr from the command:
stdin: is not a tty
Failed to start hostname.service: Unit hostname.service is masked.
Is there any way to use vivid64 . i even tried
https://atlas.hashicorp.com/larryli/vivid64
but same result
Seems as though Vagrant is throwing out an error relating to the hostname... try adding this to your vagrant file:
#host.vm.hostname = "[HOSTNAMEVM]"
host.vm.provision :shell, inline: "hostnamectl set-hostname [HOSTNAMEVM]"
Of course, set [HOSTNAMEVM] to your hostname.
What we are doing here is manually asking Vagrant to provision with a specific hostname, to attempt to fix the issue with the hostname service failing to start.
If this doesn't work, a pastebin with your Vagrantfile might help us see what might be the actual cause here.
At first, try disabling the line with "hostname" on Vagrantfile.
change the line like
config.vm.hostname = "abcd"
to
# config.vm.hostname = "abcd"

chmod fails to alter permissions in Vagrant VM

I am trying to set up a Vagrant environment to host Snowplow (https://github.com/snowplow). When I launch vagrant from a cygwin shell
$vagrant up && vagrant ssh
I get into an Ubuntu guest image (12.04), and when I attempt to install java8 into this environment using ansible, I get this message:
vagrant#precise64:~$ ansible-playbook
/vagrant/ansible-playbooks/java8-gradle.yml
--inventory-file=/vagrant/home/ansible/ansible_hosts --connection=local ERROR: The file /vagrant/home/ansible/ansible_hosts is marked as executable, but failed to execute correctly. If this is
not supposed to be an executable script, correct this with chmod -x
/vagrant/home/ansible/ansible_hosts.
The file is indeed 777:
-rwxrwxrwx 1 vagrant vagrant 24 Mar 3 19:03 ansible_hosts*
but this same file is sync'd to the host (Windows) and cygwin shows the file as 644:
-rw-r--r-- 1 rcoe Domain Users 24 Mar 3 14:03 ansible_hosts
Is there a known issue running in a headless (VirtualBox) Vagrant environment that doesn't allow permissions to be set on files that are sync'd to the host?
Thanks.
It is a known deficiency, but reportedly not a bug: Changing shared folder permissions from within virtual machine
There is a good tutorial on how to set up the synced folder in vagrant so that it would suit your needs - if you navigate to that link it will show the following snippet
config.vm.synced_folder "./", "/var/sites/dev.query-auth", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
mount_options: ["dmode=775,fmode=664"]
that shows how to adjust the permissions of the synced folder.
Alternatively you could also use a different method of syncing the folder, such as rsync (keeping in mind what the trade-offs are)
config.vm.synced_folder "/Users/ryansechrest/Projects/Sites", "/var/www/domains",
type: "rsync"
More on that here

Resources