Vagrant won't run startup-once files properly - shell

I just created a new Vagrant box using puphpet and I have put a script file in /puphpet/startup-once/once.sh
I am trying to run commands like this to modify php.ini
sudo sed -i 's|;opcache.enable=0|opcache.enable=1|g' /etc/php5/fpm/php.ini
And I am just getting errors like
No such file or directoryd /etc/php5/fpm/php.ini
Then I connect using putty and I can see that the file is actually there. Why can't Vagrant run these files? I am running Virtual Box on Windows 8 if that helps.

The problem was that I was having Windows style line endings. Converted the line endings to UNIX style and the scripts ran just fine.

Just a note that for php.ini settings you should use the php section. Your changes will be overwritten by any future $ vagrant provision due to how the puppet php module handles settings.

Related

Spark VM box NOT getting created in windows

I am new to spark. Infact, I started learning it from today from edX.I am setting up my environment in windows so that sparkvm could be used.Following are the upto date Installations that I did on my PC.
Installed Virtualbox
Installed Vagrant
created a directory
C:\Users\Macro\myvagrant
and copy VagrantFile from (https://github.com/spark-mooc/mooc-setup/archive/master.zip)
Then I executed the following command from the specified path in dos.
vagrant up but the following message is coming every time.
How would I get out of this mess?
Update:
After downloading the file and executing the suggested code.I got following error.
vagrant is not able to download the box from its cloud.
you can try the following:
if you're behind a proxy, set the proxy :
export http_proxy=http://your.proxyhost.server:port/
export https_proxy=https://your.proxyhost.server:port/
vagrant up
download the box directly and install: download from https://atlas.hashicorp.com/sparkmooc/boxes/base2/versions/0.0.7.1/providers/virtualbox.box directly or you can use a downloader tool (such as wget as below)
wget https://atlas.hashicorp.com/sparkmooc/boxes/base2/versions/0.0.7.1/providers/virtualbox.box
Then you'll need to install the box
vagrant box add sparkmooc/base2 <location of downloaded box file>
vagrant up

vagrant ssh not working in MobaXterm on Windows

I have already found "SSH to Vagrant box in Windows" and added the git bin directory to my windows PATH. I verified that it worked by starting CMD and typing ssh, and got a usage message. (Before adding the git bin directory to my path, CMD complained that ssh wasn't a valid command.)
However...when I run vagrant ssh from MobaXterm, I get the same error I did before. (A page full of ruby errors that aren't helpful to me.) When I run it as VAGRANT_LOG=debug vagrant ssh, I see:
INFO subprocess: Starting process: ["C:\\Users\\(myname)\\DOCUME~1\\MOBAXT~1\\slash\\bin/ssh.EXE"]
This is the wrong ssh executable; it's the one installed in MobaXterm and it doesn't work if run from a CMD window.
How can I get vagrant ssh to work as it should?
Part of the trick is that I don't want to use the Windows PATH for arbitrary commands—not even for ssh, really. I want to use the versions in MobaXterm for everything. All I want is to be able to run vagrant ssh the same way I would on Linux or Mac.
The workaround I have been using, which I found somewhere online (but can't find the page again), is:
vagrant ssh-config > vagrant-ssh
ssh -F vagrant-ssh default # Works exactly the way `vagrant ssh` should
"default" is the box name for a typical Vagrant environment with only a single vagrant box. If there is more than one box, replace "default" with the box name:
ssh -F vagrant-ssh host001 # Works the way `vagrant ssh host001` would on another system
This is a good workaround with minimal changes required to workflow. But I'd still like a way to get vagrant ssh working without needing the extra file in my vagrant directory.
here you can find an explanation
In the documentation, this mention is in the "Terminal tab settings"
section, so you will find this option in the "Terminal" tab.
Go to MobaXterm global settings window, then click on the "Terminal"
tab and check the "Use Windows PATH environment". Note that if you are
using a session, you will have to do the same in this session: edit
your session, then go to the "Terminal settings" tab and check the
"Use Windows PATH" option.
Call me crazy but what about doing this:
Setup Vagrant Virtualbox VM like normal
In MobaXterm, create a "Bash" shell integration with the working directory setup as the directory of the Vagrant directory for the specific VM you are doing this for (aka ... the directory where the Vagrantfile lives for this VM)
In the "Advance Shell Settings", use this command (adjust vagrant path to where ever your Vagrant is installed as MobaXterm bash sees it):
command /drives/c/HashiCorp/Vagrant/bin/vagrant ssh-config >
vagrant-ssh-config && ssh -A -F vagrant-ssh-config default
Vagrant VM needs to be up for MobaXterm Bash entry for the VM to work. I just setup two Bash shell settings for two Vagrant Virtualbox VMs I created and it seems to work just fine.
Updated: I went a little further since I've figured this out .. at least for me I did :). I added additional CMD shell sessions MobaXterm for each of my Vagrant VM. These additional CMD shell sessions do Vagrant halt, up, and restart (combo of halt and up) commands against the VMs they are specific to. This is what restart looks like:
vagrant halt
vagrant up
set /p value="Press Enter to continue"
exit
The Startup Directory for the above session is, again, the directory where the Vagrantfile lives for this VM. Oh, and make sure that "Use Windows PATH" is checked in Terminal Settings.
you can install git (https://git-scm.com/downloads) during install git choose "use git and optional Unix tools from the windows command prompt"
Download msysgit from msysgit project page and include msysgit/bin folder to PATH, now you can run ssh and vagrant ssh form your terminal on windows.

Unable to create vagrant file (homestead.yaml) on windows

I'm gonna to use vagrant on my windows desktop to develop Laravel project. I have followed all the steps to do that. But it has been failed to create homestead.yaml using bash init.sh command.
Below is the error :
Fakhreddin#Lenovo-PC3 /cygdrive/d/laravel-vagrant/homestead
$ bash init.sh
cp: unwritable ‘/home/Fakhreddin/.homestead/Homestead.yaml’ (mode 0500, r-x------); try anyway?
I'm using Cygwin for simulating Unix terminal in the Windows.
(Copy of the comment I wrote above)
Never used Cygwin in my life, but what I would try is to run it as Administrator and re-try.
Otherwise, you may want to consider changing console client. For example, if you install Git, you should be able to use Unix commands via standard Windows console.
I would seriously point the fault at Cygwin, or its settings. I am a member of a team in which all of us run Homestead on Windows 7, with no problems at all. The difference is, we use native Windows command line.

Vagrant run command: Where, what and why?

Following this tutorial on the Vagrant website, I was able to get a virtual machine up and running very easily, but now I'm trying to create a different virtual machine by forking a repository linked below.
The README in this repository tells me to do this:
$ git clone git://github.com/honza/django-chef.git
$ cd django-chef
# add yourself to the "users" array in the Vagrantfile
$ sudo echo "127.0.0.1 example.example.com" >> /etc/hosts
$ vagrant up
$ fab vagrant:honza bootstrap # replace with your name
$ vagrant ssh
$ run # ME (doctordoder): This command is not found?
"Then open your browser to http://example.example.com:3456."
The difference being that the other tutorial stops at vagrant up, and then the website is available.
When I tried to do these extra steps with this more difficult repository, I got this (I did these commands after I had already ran vagrant up in the django-chef directory successfuly):
Where is this so called "run" command in vagrant? Why do I need it? And why is it unavailable to me?
Because it's not a vagrant command :) It's a custom command that's put in by the chef provisioner.
I scanned the source code of the repository and you can find a .erb template in the following folder:
django-chef/cookbooks/example/templates/default/bashrc.erb [line 23]
within this file there is a custom function defined named "run". This function will execute the "runserver" command form django (link)
The file
django-chef/cookbooks/example/recipes/default.rb [line 23]
is responsible for updating the .bashrc file on the guest machine and that's why you can call the "run" command from inside the guest machine.
So basically you are looking at the wrong place.

Cannot run "vagrant up" in PhpStorm 6 in command line

I am trying to launch my Vagrant directly from Phpstorm 6 but I am not able to find the command (Windows).
Screenshot : http://i.stack.imgur.com/d8aUA.png
Is there anything I could do to make it works ?
Thanks!
Have you created an alias for vagrant in "Settings | Command Line Tool Support" ?
Command Line Support Tool does not know what vagrant is, so it tries to execute whole command as is. The problem is -- proper name of app should be vagrant.bat (or vagrant.cmd -- do not remember) -- IDE does not add .bat/.exe/etc automatically like DOS/Windows does.
So either use vagrant.bat up command instead .. or (which is better) create an alias.
P.S.
PhpStorm v7 will search for .bat/.cmd/.exe/etc in your PATH if exact command cannot be found. Still -- making an alias is the best/safest way to go here in Command Line Tools.
An excerpt from: https://www.jetbrains.com/phpstorm/webhelp/vagrant.html
Make sure that the parent folders of the following executable files
are added to the system PATH variable:
vagrant.bat or vagrant from your Vagrant installation. This should be done automatically by the Vagrant installer.
If you've installed Vagrant the standard way then just restart the command prompt itself or phpStorm so it reloads the PATH. Else just find that bat file and run it manually to see if it works or better add the path to the system PATH var.

Resources