Vagrant provision not working - vagrant

I have a problem with installing softwares using the vagrant provisions . I just tried to install git but I get this error :
==> default: stdin: is not a tty
==> default: git-email git-gui gitk gitweb diffutils-doc
==> default: The following NEW packages will be installed:
==> default: git git-man liberror-perl patch
==> default: 0 upgraded, 4 newly installed, 0 to remove and 179 not upgraded.
==> default: Need to get 6,730 kB of archives.
==> default: After this operation, 15.4 MB of additional disk space will be used.
==> default: Do you want to continue [Y/n]?
==> default: Abort.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
my Vargantfile looks so :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.provision "shell", path: "bootstrap.sh"
end
and my bootstrap.sh contains exactly :
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install git
I tried it on mac and windows and get the same errors , I am using vagrant 1.7.2

You need to add the -y flag when installing stuff from your bootstrap file, otherwise the system will wait for a confirmation
sudo apt-get -y install git

Related

I can't install RVM and Ruby on Vagrant (box "hashicorp/precise64")

everyone! I've followed the instructions from https://rvm.io/integration/vagrant
So in Vargantfile I have:
config.vm.box = "hashicorp/precise64"
config.vm.provision :shell, path: "provision/install-rvm.sh", args: "stable", privileged: false
config.vm.provision :shell, path: "provision/install-ruby.sh", args: "1.9.3", privileged: false
config.vm.provision :shell, path: "provision/install-ruby.sh", args: "2.0.0 rails haml", privileged: false
in install-rvm.sh:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s $1
in install-ruby.sh:
source $HOME/.rvm/scripts/rvm || source /etc/profile.d/rvm.sh
rvm use --default --install $1
shift
if (( $# ))
then gem install $#
fi
rvm cleanup all
but after vagrant up it says:
==> default: gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
==> default: gpg: key D39DC0E3: "Michal Papis (RVM signing) <mpapis#gmail.com>" not changed
==> default: gpg: Total number processed: 1
==> default: gpg: unchanged: 1
==> default: /tmp/vagrant-shell: line 4: curl: command not found
==> default: Running provisioner: shell...
default: Running: /tmp/vagrant-shell20170120-19193-117iyxj.sh
==> default: /tmp/vagrant-shell: line 3: /usr/local/rvm/scripts/rvm: No such file or directory
==> default: /tmp/vagrant-shell: line 3: /etc/profile.d/rvm.sh: No such file or directory
==> default: /tmp/vagrant-shell: line 5: rvm: command not found
==> default: /tmp/vagrant-shell: line 13: rvm: command not found
But if I run the same provision with rvm and ruby on "ubuntu/trusty64"
everything works just fine
RVM depends on curl - add extra line to install curl like:
apt-get install curl
before any calls to rvm scripts

Vagrant box could not be found or could not be accessed in the remote catalog - incompatible curl version

I just downloaded Vagrant and did the settings as well as install virtual box. I just can't start my project (vagrant up). I have a vagrant file and so on. What can I do?
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'scotch/box' could not be found. Attempting to find and install
...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'scotch/box' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/scotch/box"]
There seems to be an issue with vagrant 1.8.7 and the embedded curl version vs the mac os binary (shipped by default on mac os Sierra and others) - remove the embedded one
sudo rm /opt/vagrant/embedded/bin/curl
Note: you also need to remove the embedded curl when you add a vagrant box (remotely or locally) so if you get the same error when running vagrant box add .... just remove the curl from vagrant and it will work
Just wanted to update this post. I ran into this error running macOS Sierra and a fresh Vagrant 1.8.7 install and noticed Vagrant just updated. As of Vagrant 1.9.0 this error appears to have been fixed.
Had a similar problem with Sierra (with additional brew installs - which granted could have an impact).
Above sudo rm /opt/vagrant/embedded/bin/curl did not work still got: SSLRead() return error -36.
Tried suggestion from http://slick.pl/kb/software/vagrant-fix-for-error-60-ssl-read/
Any case:
cd ~
cd .vagrant.d/tmp/
rm -rf ~/.vagrant.d/tmp/
vagrant box add --insecure laravel/homestead
Installed successfully.
I just experienced this error.
In my case I installed vagrant via apt-get which installed 1.7.x..
I removed 1.7.x and installed 2.0.3 directly https://www.vagrantup.com/downloads.html
I had this same problem on MacOS Mojave, and Vagrant version 1.9.3, when trying to use the box: centos/7.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'centos/7' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/centos/7"]
Error: The requested URL returned error: 404 Not Found
I updated to Vagrant 2.2.5 and it worked as expected:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
default: URL: https://vagrantcloud.com/centos/7
==> default: Adding box 'centos/7' (v1902.01) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box
default: Download redirected to host: cloud.centos.org
==> default: Successfully added box 'centos/7' (v1902.01) for 'virtualbox'!
You should try update Vagrant to the latest version:
sudo add-apt-repository ppa:tiagohillebrandt/vagrant
sudo apt update
This will add a repository for your actual ubuntu version. If you are on 20.10 (groovy) replace groovy with focal and call sudo apt update again.
Then install vagrant again:
sudo apt install vagrant
And update all plugins:
vagrant plugin update

"Only one of `path` or `inline` may be set" on vagrant up

I am trying to use vlad to install drupal using vagrant on windows.
I installed vagrant.
I have installed Cygwin using babun and finally I got to install ansible.
When vagrant up I get : "Only one of path or inline may be set" error.
{ vlad-master } ยป vagrant up ~/vlad-master 1
Found project settings file: C:/Users/maggie/.babun/cygwin/home/maggie/vlad-master/vlad_guts/vlad_settings.yml
Bringing machine 'vlad' up with 'virtualbox' provider...
==> vlad: Running triggers before up...
==> vlad: Executing pre 'provision' setup trigger
==> vlad: Executing command "ansible-galaxy install -r vlad_guts/playbooks/requirements.yml --force"...
==> vlad: - extracting aberdeencloud_cli to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/aberdeencloud_cli
==> vlad: - aberdeencloud_cli was installed successfully
==> vlad: - extracting pantheon_cli to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/pantheon_cli
==> vlad: - pantheon_cli was installed successfully
==> vlad: - extracting imagemagick to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/imagemagick
==> vlad: - imagemagick was installed successfully
==> vlad: - extracting sendmail to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/sendmail
==> vlad: - sendmail was installed successfully
==> vlad: - extracting tomcat to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/tomcat
==> vlad: - tomcat was installed successfully
==> vlad: - extracting solr to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/solr
==> vlad: - solr was installed successfully
==> vlad: - adding dependency: hashbangcode.tomcat
==> vlad: - extracting drush to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/drush
==> vlad: - drush was installed successfully
==> vlad: - extracting platformsh_cli to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/platformsh_cli
==> vlad: - platformsh_cli was installed successfully
==> vlad: - downloading role 'tomcat', owned by hashbangcode
==> vlad: - downloading role from https://github.com/hashbangcode/ansible-role-tomcat/archive/master.tar.gz
==> vlad: - extracting hashbangcode.tomcat to /home/maggie/vlad-master/vlad_guts/playbooks/ext_roles/hashbangcode.tomcat
==> vlad: - hashbangcode.tomcat was installed successfully
==> vlad: Command execution finished.
==> vlad: Executing 'up' setup trigger
==> vlad: Creating C:/Users/maggie/.babun/cygwin/home/maggie/vlad-master/vlad_guts/host.ini
There are errors in the configuration of this machine. Please fix
the following errors and try again:
shell provisioner:
* Only one of `path` or `inline` may be set.
Read the vagrant shell provisioning documentation
The shell provisioner takes various options. One of inline or path is
required:
inline (string) - Specifies a shell command inline to execute on the
remote machine. See the inline scripts section below for more
information.
path (string) - Path to a shell script to upload and execute. It can
be a script relative to the project Vagrantfile or a remote script
(like a gist).
so you can either have
Vagrant.configure("2") do |config|
config.vm.provision "shell",
inline: "echo Hello, World"
end
or
Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "script.sh"
end
You can review your shell provisioner form your Vagrantfile and make sure the provisioner does not have path and inline within the same block, it must be one or the other

vagrant bootstrap: source ~/.profile not working

So I'm trying to install nvm and node in vagrant but can't seem to make it work.
Apparently I'm having trouble getting it to load/read nvm since nvm requires you to reload your terminal. ~/.profile doesn't seem to be doing the job
using ubuntu/xenial64
This is my bootstrap.sh file
#install nvm
cd ~
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh -o install_nvm.sh
bash install_nvm.sh
#this command makes it so that you don't need to re-open the terminal for 'nvm' to be available
source ~/.profile
#use nvm to install node
nvm install 6.2.2
nvm use 6.2.2
the error I get (slightly modified to hide personal information):
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /installation_data => C:/work/<PATH_OMMITED>
==> default: Running provisioner: shell...
default: Running: C:/Users/ahmed/AppData/Local/Temp/vagrant-shell20160703-8248-1c82peg.sh
==> default: => Downloading nvm from git to '/home/ubuntu/.nvm'
=> default:
==> default: Cloning into '/home/ubuntu/.nvm'...
==> default: * (HEAD detached at v0.31.2)
==> default: master
==> default: => Appending source string to /home/ubuntu/.bashrc
==> default: => Close and reopen your terminal to start using nvm
==> default: /tmp/vagrant-shell: line 11: nvm: command not found
==> default: /tmp/vagrant-shell: line 12: nvm: command not found
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
Instead of sourcing ~/.profile try this:
echo "--- Installing Node.js ---"
git clone https://github.com/creationix/nvm.git /home/vagrant/.nvm && cd /home/vagrant/.nvm && git checkout `git describe --abbrev=0 --tags`
source /home/vagrant/.nvm/nvm.sh
nvm install 6.2.2
nvm use 6.2.2
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
echo $n
Please refer this post. Tested on scotch box. Seems to just work fine.

using Vagrant getting a shell script issue and failure

I have the following details:
Vagrant File:
Vagrant.configure("2") do |config|
config.vm.box = "Precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.synced_folder "./Public","/var/www/",create:true
config.vm.network :private_network, ip: "192.168.55.55"
config.vm.provision :shell, :path => "setup.sh"
end
Shell File:
sudo apt-get -y update
sudo apt-get install apache2 php5 libapache2-mod-php5
sudo sudo apachectl restart
The shell is s little limited but i want to get it to work first before i attempt all the other php stuff etc
The error i get starts here:
Do you want to continue [Y/n]? Abort.
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell
Stdout from the command:
then continues with trying to get or hit files
Fetched 3,018 kB in 4s (681 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
Suggested packages:
www-browser apache2-doc apache2-suexec apache2-suexec-custom
openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
0 upgraded, 10 newly installed, 0 to remove and 155 not upgraded.
Need to get 1,845 kB of archives.
After this operation, 5,314 kB of additional disk space will be used.
Do you want to continue [Y/n]? Abort.
Stderr from the command:
stdin: is not a tty
i have even tried:
config.vm.network :forwarded_port, host: 3003, guest: 3000
And thats it failure, althought when i do go to localhost:3000 or that i get:
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
Protocol mismatch.
I am on a MAC OSX 10.8.5
also the sections where it say
Do you want to continue [Y/n]?
i don't get to choose it automatically does this for me.
Can you try adding a '-y' to apt-get install? like: sudo apt-get -y install apache2 php5 libapache2-mod-php5 to overcome the 'Do you want to continue [Y/n]'? - nikhil

Resources