Ansible playbook throwing `playbook does not exist on the guest` when testing with Vagrant machine - ansible

When running ansible playbook in windows vagrant image, output looks like:
==> default: Machine booted and ready!
Sorry, don't know how to check guest version of Virtualbox Guest Additions on this platform. Stopping installation.
==> 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.1.12
default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
default: /vagrant => /Users/aaron.west/Workspace/hss-iaas/ansible-repo/tmp
==> default: Running provisioner: ansible_local...
`playbook` does not exist on the guest: /vagrant/test/local.yml
The playbook can be found here: https://galaxy.ansible.com/lean_delivery/java
and the vagrant windows server 2016 image that i'm using is: mwrock/Windows2016
the playbook looks like:
- hosts: local
gather_facts: yes
connection: local
become: yes
become_user: root
roles:
- ../roles/java

As per the ansible_local documentation:
The Ansible Local provisioner requires that all the Ansible Playbook
files are available on the guest machine, at the location referred by
the provisioning_path option. Usually these files are initially
present on the host machine (as part of your Vagrant project), and it
is quite easy to share them with a Vagrant Synced Folder.
To do so, add the following:
config.vm.synced_folder ".", "/vagrant"
This configuration shares the vagrant folder from the host in the "/vagrant" folder on the guest, where it seems to look for the playbook as can be seen in the error message you get.

Running provisioner: ansible_local – so Vagrant tries to execute playbook inside the guest.
You might want to refactor your playbooks to work with ansible provisioner.

Better use:
config.vm.synced_folder ".", "/vagrant", create: true
Sometimes this directory is missing in the image and this leads to the same error.

Related

how to solve this SMB share folder when vagrant sync folder fail in this case?

I have a vagrant in my Win10 PC.
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.synced_folder "D:/Users/88888888/vagrant_proj/vagrant_data", "/vagrant_data"
config.vm.network "private_network", ip: "172.22.244.28"
end
When I vagrant up my vm, I get below error when sync folder:
MINGW64 ~/vagrant_proj/vagrant_vm/vmware_desktop_centos7
$ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.22.244.28
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.22.244.28:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]): ABC\88888888
default: Password (will be hidden):
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
default: Password (will be hidden): Aircraft04!
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Mounting SMB shared folders...
default: D:/Users/88888888/vagrant_proj/vagrant_data => /vagrant_data
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o vers=2.0,credentials=/etc/smb_creds_vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //10.0.129.112/vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593 /vagrant_data
The error output from the last command was:
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
how to solve this SMB share folder?
the version is below:
$ vagrant.exe --version
Vagrant 2.2.19
and I use the vagrant HyperV provider.

Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer

It seems I can't SSH to my virtual box.
I have a virtual box running with Win7. The host PC is also in Win7.
The virtual box was created through Vagrant with the following Vagrantfile.
Vagrant.configure("2") do |config|
config.vm.box = "http://aka.ms/vagrant-win7-ie11"
end
Open cmd. Go to the root folder of the VagrantFile.
Execute the following command:
vagrant up
cmd displays:
Bringing machine 'default' up with 'virtualbox' provider...
==> 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: 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
Timed out while waiting for the machine to boot...
Time out appears though the virtual box has already finished the boot. (Checking via VirtualBox Manager)
Execute the following command:
vagrant ssh
cmd displays:
ssh_exchange_identification: read: Connection reset by peer
While debugging the vagrant ssh, I may have found some useful logs:
INFO subprocess: Starting process: ["C:\\Program Files\\Git\\usr\\bin/ssh.EXE"]
INFO ssh: Invoking SSH: ss ["vagrant#127.0.0.1", "-p", "2222", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-o", "IdentitiesOnly=yes", "-i", "C:/Users/hostpcname/.vagrant.d/insecure_private_key"]
Can you suggest some ways on how to get out of this?
I've tried the non-Windows image - hashicorp/precise64, and it worked fine.
I have the same issue. Do by follow this step and working for me.
vagrant reload
and
vagrant ssh
again and working fine
These steps will work
vagrant halt
open virtual box and uncheck hardware virtualization , save it
vagrant up
vagrant ssh
Note: vagrant halt is must, settings can't be edited in running state
The following commands worked for me.
vagrant halt
vagrant up
vagrant ssh
Enable de virtualization on BIOS
After rebooting my computer and enabling intel virtualization in BIOS, I was able to get past this.
I was getting error as : ssh_exchange_identification connection reset by peer
Please follow below link ,it worked for me.
https://talk.openmrs.org/t/error-on-vagrant-up/8833/30
Step:
Please open virtualbox and check if any vm is running.
Run vagrant destroy to remove all vms created by current Vagrantfile.
Remove .vagrant directory in the bahmni-vagrant directory.
Make sure you have the same Vagrantfile file as https://github.com/Bahmni/bahmni-vagrant/blob/master/Vagrantfile 37.
Run vagrant up. Monitor virtualbox while it is starting up.

Vagrant Laravel Homestead - error when running vagrant up

I have followed the tutorial on https://laravel.com/docs/5.0/homestead and when running the step 'vagrant up', I get the following error message (below)
Any ideas what the problem is? Running latest version of Oracle VirtualBox and the latest version of Vagrant. Regards
--
C:\Users\Anders\Vagrant\Homestead>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead-7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8000 (host) (adapter 1)
default: 443 (guest) => 44300 (host) (adapter 1)
default: 3306 (guest) => 33060 (host) (adapter 1)
default: 5432 (guest) => 54320 (host) (adapter 1)
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...
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!
GuestAdditions versions on your host (5.0.16) and guest (5.0.12) do not match.
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
linux-headers-3.19.0-25-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the
box /tmp/VBoxGuestAdditions.iso
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting rea
d-only
Installing Virtualbox Guest Additions 5.0.16 - guest version is 5.0.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.16 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.12 of VirtualBox Guest Additions...
Stopping VirtualBox Additions ...fail!
(Cannot unload module vboxguest)
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Stopping VirtualBox Guest Addition service ...done.
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 5.0.16. Some
functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/Anders/Vagrant/Homestead
default: /home/vagrant/Code => C:/Users/Anders/Code
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,
actimeo=1 home_vagrant_Code /home/vagrant/Code
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,actimeo=1 home_vagran
t_Code /home/vagrant/Code
The error output from the last command was:
unknown mount option `actimeo=1'
valid options:
rw mount read write (default)
ro mount read only
uid =<arg> default file owner user id
gid =<arg> default file owner group id
ttl =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode =<arg> mode of all directories
fmode =<arg> mode of all regular files
umask =<arg> umask of directories and regular files
dmask =<arg> umask of directories
fmask =<arg> umask of regular files
C:\Users\Anders\Vagrant\Homestead>
--
vagrant file:
--
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
if File.exists? homesteadYamlPath then
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
elsif File.exists? homesteadJsonPath then
Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
end
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end
--
yaml file:
--
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/Vagrant/Homestead/homestead.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
type: "nfs"
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
hhvm: true
databases:
- homestead
The issue you're experiencing with Homestead has been documented in Github. There is a workaround provided, which is as follows:
Solution: Remove type: "nfs" on your folders of Homestead.yaml.
http://docs.vagrantup.com/v2/synced-folders/nfs.html
"Windows users: NFS folders do not work on Windows hosts. Vagrant will
ignore your request for NFS synced folders on Windows.
Original Answer (for the question before it was edited)
Now the issue seems to be with your ssh key, or lackthereof.
No such file or directory # rb_sysopen - C:/Users/Anders/.ssh/id_rsa (Errno::ENOENT)
The section in the guide you linked titled Set Your SSH Key has the following instructions to help you generate one (trimmed to the relevant Windows instructions):
Set Your SSH Key
[...]
On Windows, you may install Git and use the Git Bash shell included with Git to issue the command above. Alternatively, you may use PuTTY and PuTTYgen.
Once you have created a SSH key, specify the key's path in the authorize property of your Homestead.yaml file.
If you are not that comfortable with commandlines, I would recommend using the PuTTYgen method.
This is a problem with your Homestead.yaml file in ~/.homestead directory. I need see the file content to help you more.
After you had fixed the indention style to use only space characters, the another problem happenned because you not generate a pair (public and private) of keys yet. To do that:
mkdir -p ~/.ssh && cd ~/.ssh
ssh-keygen -b 2048 -t rsa -C "you#domain.com"
You can let the default file name (id_rsa), type the password and repeat the same password.
In case anyone else ends up here via Google and didn't read all the comments too well (like I did).
I ran into the same issue of not being able to vagrant up with the following error:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o actimeo=1,nolock,uid=1000,gid=1000 var_www_dev.mybox /var/www/dev.mybox
The error output from the command was:
fmask =<arg> umask of regular files
As Lucas mentioned here Windows users can install the vagrant-winnfsd plugin which allows you to use NFS shared folders in Vagrant and Homestead).
So I solved this error by running vagrant plugin install vagrant-winnfsd followed by a vagrant up.

I can't connect to a Vagrant handled VM: `ssh` executable not found in any directories in the %PATH%, but I have it

I am absolutly new in Vagrant and I have the following problem. I am using Windows 8.1.
I have done the following operations:
First I have download this into a folder of my host from github, by this statment:
git clone https://github.com/Udacity/ud381
Then I performed:
vagrant up
that downloaded the Vagrant Box containing the guest VM
and when now I perform the vagrant up command I obtain this message:
C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'udacity/ud381' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due
==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default: Failed connect to atlas.hashicorp.com:443; No error
==> default:
==> default: If you want to check for box updates, verify your network connectio
n
==> default: is valid and try again.
==> 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: 5000 => 5000 (adapter 1)
default: 22 => 2222 (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: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/Andrea/Documents/workspaces/Real-Time/ud381
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.
I think that it is correct but I am not absolutly sure about it because it seems that I have some warning message but it say: default: Machine booted and ready! so I think that it is ok (is it ok?)
Then I try to connect to it by SSH performing the vagrant ssh statment but I obtain this error message:
C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use your favorite SSH client with the following
authentication information shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/Andrea/Documents/workspaces/Real-Time/ud381/.vagrant/machi
nes/default/virtualbox/private_key
Searching on Google I found that to use this statment I need the git path into the PATH environment variable. I check and I have it setted, infact inside the PATH variable I have these 2 values:
C:\HashiCorp\Vagrant\bin;C:\Program Files\Git\bin
the first one is the vagrant path and the second one the Git path.
So this is not the problem. Searching online I also found this StacOverflow discussion:
`ssh` executable not found in any directories in the %PATH%
that send to this link for this kind of problem: https://gist.github.com/haf/2843680
In this link it show how to modify an ssh.rb file into this folder C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb
The problem is that I have not this folder but something like this:
C:\HashiCorp\Vagrant\embedded\lib\ruby\gems\2.0.0\gems\
and this folder don't contain the *vagrant-1.0.3\lib\vagrant* subfolder (that contain the ssh.rb file) but contain 3 directory respectivelly named rake-0.9.6, rdoc-4.0.0 and test-unit-2.0.0.0 that don't contain the ssh.rb file.
Searching this file I found 2 different version into these folder:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v1\config
and
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v2\config
I think that maybe the difference from the tutorial could depend by the fact that it is referred to a very old Vagrant version (it is 4 year old) and I have installed the 1.7.4 version of Vagrant.
So how can I connect in SSH to the VM handled by Vagrant?
The error message
C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh `ssh`
executable not found in any directories in the %PATH% variable. Is an
SSH client installed?
states that the cli you are currently using (wich is probably cmd or powershell when you are working under windows) could not find an installed ssh client. That means your cli was not able to find a programm that can handle connecting to another server (in this case your vagrantbox) via ssh.
This is a pretty common scenario since windows does not come with an ssh client out of the box (unlike ubuntu or osx).
AFAIK there is no ssh program/command that you can easily install and put into your PATH so that it will work with cmd.
What you probably want to do in this situation is installing a different cli that comes with these features. You have several Options here, they are also stated in the error message:
Try installing Cygwin, MinGW or Git, all of which
contain an SSH client
I recommend you using Git Bash which you probably already have installed on your system since you are using git.
So to perform a vagrant ssh your first step will be starting Git Bash either by executing the program itself (which comes with git, on my system it could be found under: C:\Program Files\Git\git-bash.exe) or by right clicking in a directory listing in Windows Explorer and selecting Git Bash here (this will only work if you checked a certain box upon Git install).
It will open a new cli which works with linux like commands.
You should be able to cd into your vagrant directory and perform a vagrant ssh now.
The solution you linked to in your question no longer seems to work since the path of the ssh client comming with git seems to have changed.
See Ygor Thomaz' comment in the other SO post you found. The PATH path has changed to:
C:\Program Files\Git\usr\bin
..so run this in cmd:
set PATH=%PATH%;C:\Program Files\Git\usr\bin
Related:
How do you update the GIT_SSH environment variable on Windows
https://stackoverflow.com/a/16247703/1869660

Vagrant with Ansible for Windows VM

I am trying to run Vagrant with Ansible on my Mac to create and provision a Windows 7 VM. I am able to "vagrant up" when I don't invoke Ansible in the Vagrantfile.
I am using the following playbook.yml
---
- hosts: all
tasks:
- name: run win ping
win_ping:
When I add the ansible code to my Vagrantfile, I get the following error
GATHERING FACTS ***************************************************************
failed: [default] => {"failed": true, "parsed": false}
/bin/sh: /usr/bin/python: No such file or directory
To me, this error means it fails to find Python because it is looking for Python as if it is a Linux machine.
Separately, I have run
ansible windows -m win_ping
where windows is the IP address to the VM brought up by Vagrant so I suspect the issue is not with Ansible but with how Vagrant is invoking Ansible.
Has anyone tried Vagrant + Ansible for a Windows VM? Is there something obvious that I am missing (perhaps an option to pass to Ansible)?
I am using Vagrant version 1.7.2 and Ansible version 1.8.3
With Ansible provisioning a Windows box (either Vagrant, VM or real machine) the configuration is much more important in the first place. Before crafting your playbook, you should have a correct configuration in place.
Having a Windows box managed by Vagrant, your configuration file group_vars/windows-dev should contain something like:
ansible_user: IEUser
ansible_password: Passw0rd!
ansible_port: 55986 # not 5986, as we would use for non-virtualized environments
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
Be sure to insert the correct credentials and choose the right port for ansible-port. Working with Vagrant, you can get the correct port from the log-messages produced by Vagrant after a vagrant up. In my case this looks like this:
==> default: Forwarding ports...
default: 5985 (guest) => 55985 (host) (adapter 1)
default: 5986 (guest) => 55986 (host) (adapter 1)
My Vagrantfile could be found here, if you´re interested. It uses the Microsoft Edge on Windows 10 Stable (14.xxx) image from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms.
Now the win_ping module should work - assuming that you´ve done all the necessary preparing steps on your Windows box which center around executing the script ConfigureRemotingForAnsible.ps1 (more Information could be found in the Making Windows Ansible ready chapter in this blog post):
ansible windows-dev -i hostsfile -m win_ping
Only, if this gives you an SUCCESS you should proceed with crafting your playbook.
In my Windows provisioning playbook I set this in the header:
gather_facts: no

Resources