How Export my Vagrant Project ?

70 views
Skip to first unread message

Zeus_Dev

unread,
May 28, 2019, 11:35:07 AM5/28/19
to Vagrant
Hello everyone,

So Im working on a project using Vagrant box it's a Ubuntu 16.04 (PHP 7.3) and the project is a Drupal, but Im wondering how can I export my whole vagrant project ?

Im a newbie on this technology, so is just copy/paste the whole vagrant folder and export it to any machine (with a VirtualBox and Vagrant already installed of course), or is there any technique that allows me to export my project a 

better and cleaner way, that guarantee me that it's gonna work.

So anyone can explain to me how to dit :)

Thanks for advance.

Dennis Chang

unread,
May 28, 2019, 11:39:12 AM5/28/19
to Vagrant
Take a look at 'vagrant package'

There are also a lot of tutorials on how to create 'base boxes' or basically repackaging and making a new base box.


Zeus_Dev

unread,
May 28, 2019, 11:51:08 AM5/28/19
to Vagrant
Thanks !, I'll look for the Vagrant package command, but Im having another question, The first time I installed my vagrant box, I was using the provision.sh that was installing the PHP 7.0, but I updated the PHP version to 7.3 directly into my vagrant image box, so does the package command will take all the modifications I did on my VM Ubuntu ?
Message has been deleted

Dennis Chang

unread,
May 28, 2019, 12:09:26 PM5/28/19
to Vagrant
Short answer, yes, it will package all modifications.

Long answer:

When you do 'vagrant up' with a Vagrantfile that references 'bento/ubuntu-16.04' for instance,

you're checking if you haven't downloaded it already, i.e. 'vagrant box list', and if not, vagrant downloads it.


You can do it yourself. Download the file. And then 'vagrant box add bento/ubuntu-16.04 virtualbox.box'
this should add the box to vagrant.

'vagrant up' creates a machine (live instance) from a box. 'vagrant package' converts a machine to a box.

Zeus_Dev

unread,
May 29, 2019, 9:57:59 AM5/29/19
to Vagrant
Thanks for your explanations :)

I tried the vagrant package you told me and its worked, I had a .box file, so I Uploaded to the vagrant cloud to test it, I configured my vagrantfile, but none of my project drupal is in my box, only the server config (PHP, Apache2, MySQL DB).

So is there any way to bring my drupal project/folder on this box ?

Dennis Chang

unread,
May 29, 2019, 10:45:44 AM5/29/19
to Vagrant
Hi Zeus_Dev,

I don't really understand what you mean by 'is there any way to bring my drupal project/folder on this box'?

So if you created your machine (not box), which includes your project files, i.e. PHP, etc. And you packaged your machine (into a box) correctly, then those project files *should* be contained within the new box.

Can you list the instructions you performed to package your machine?

Alvaro Miranda Aguilera

unread,
May 29, 2019, 11:49:07 AM5/29/19
to vagra...@googlegroups.com
hello

vagrant up will configure a VM based on Vagrantfile and provisioning

if you want to have a new base box that include more than just the base OS

have a look at packer.io 

it will create a box and you can run the same scripts




--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/4248a47a-8bdc-4230-ac57-117ac9cc6a5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Zeus_Dev

unread,
May 29, 2019, 4:32:22 PM5/29/19
to Vagrant
Hello (:

Im sorry i'm a newbie in this Vagrant universe.

So let me explain to you what Im having right now :

- a Vagrant folder (contains my vagrantfile and a provision.sh shell to execute, that shell contains a Git cloning Drupal project, PHP, Apache Installation/configuration) everything is working perfectly VM is launching perfeclty with my drupal folder.

Now I want to export all that (The VM wich is a Ubuntu 16.04 WITH the drupal folder, So I used the vagrant package, and it worked ! so I had m +900MB box(Vm), I uploaded to my Vagrant cloud choosed as a provider virtualbox till now everything is ok.

Now  I want to try my new exported machine, so I executed the command : vagrant up myproject and it worked ! but I didn't get my drupal folder that I had, all my Server configs are working perfectly (my PHP update/my DB), except the drupal folder, the project that I work on.

So My question was, is there any way to attach, make my drupal folder go with the box, or more clearly, I want when I execute the command  vagrant up myproject I have the VM+my drupal folder project.

:)

Dennis Chang

unread,
May 29, 2019, 5:45:02 PM5/29/19
to Vagrant
Hi Zeus_Dev,

I think I understand why it's not working.

When you run the command 'vagrant up myproject' this command looks for a machine named myproject to start up.
If it doesn't find it, it looks for a Vagrantfile in the local directory (which I'm guessing is the original Vagrantfile).
So it starts up from the original box you used in your Vagrantfile.

if you uploaded your box to a Vagrant cloud, then you need to reference that box in a new Vagrantfile (not use the old one).

So let me be specific:

# old Vagrantfile (pretend your using bento/ubuntu-14.04 as base box to create your drupal server)
Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-14.04"
  # you did all your provisioning in a script
end

# after you package the machine (lets say it's called zeus_dev/drupalproject)
# those project files should already be inside the box

# new Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "zeus_dev/drupalproject"
end

So inside a new directory, with a new Vagrantfile which references your vagrant-cloud box.
You can spin up a new machine (and it should already contain your drupal project files).

Remember, package takes a machine and turns it into a box. When you do 'vagrant up' it takes a box and creates a machine.
I think what you did wrong is that you're not referencing correctly the box you created.

Hope that helps,

Zeus_Dev

unread,
May 29, 2019, 6:15:19 PM5/29/19
to Vagrant
Thank you so much Dennis, it works and the box is installed correctly :)

But Im having another problem now |:, this time on the provision.sh

So actually no need to add the installation of the PHP/Apache/MySQL packages because when I packaged my Box and Installed it on my machine for testing, all the configs are good.

Now what I want to do is to create a folder, configure my Apache Server so the document root will be directly my drupal folder, and the most important is to clone the drupal folder that I've been working, wich is on my repo drupal on the gitlab, wich is a public repo.

So I wrote this provision shell script : Pastebin I pasted the code on Pastebin, much more cleaner than here (: .

Now the problem here, is that nothing is cloned, it hangs on this message :     default: Cloning into '.'...

Dennis Chang

unread,
May 30, 2019, 10:15:08 AM5/30/19
to Vagrant
Hi Zeus_Dev,

Can you provide the entire log ... all the way to "default: Cloning into "." ...

Zeus_Dev

unread,
May 30, 2019, 11:14:29 AM5/30/19
to Vagrant
yes, here is the entire log from the begining of the installation of the box till the Cloning into "." ... 

Dennis Chang

unread,
May 30, 2019, 3:20:19 PM5/30/19
to Vagrant
Hi Zeus_Dev,

So I noticed that

$GIT_PROJECT_REPOSITORY


is commented out.

Try printing out those variables to standard output and see if they display.

Zeus_Dev

unread,
May 30, 2019, 3:39:45 PM5/30/19
to Vagrant

Hello Denni :)

Yeah I did what you told me to print the details of the variables  : https://pastebin.com/DzGgB9N1
And this is my provision.sh : https://pastebin.com/SZJ1w04n
And here is my vagrantfile : https://pastebin.com/h941p7Lw

And it still hangs on     default: Cloning into '.'...

Dennis Chang

unread,
May 30, 2019, 3:41:51 PM5/30/19
to Vagrant
Still stopping at the same place? git clone?

Then perhaps try 'git clone --verbose' and see if it prints out more information.

Zeus_Dev

unread,
May 30, 2019, 3:58:43 PM5/30/19
to Vagrant
I added this : sudo git clone --verbose --branch $GIT_PROJECT_BRANCH $GIT_PROJECT_REPOSITORY .
And nothing is changed

Zeus_Dev

unread,
May 30, 2019, 4:05:21 PM5/30/19
to Vagrant
Oh there is a bit of change now;     
    default: Cloning into '.'...
    default: POST git-upload-pack (152 bytes)

And it hangs ...

Dennis Chang

unread,
May 30, 2019, 4:21:04 PM5/30/19
to Vagrant
I believe your provision script is run as root. So sudo isn't necessary (probably doesn't hurt either).

But I believe that git requires configuration settings.
I.e. user.name and user.email.

Perhaps you can run the command "git config user.name" and "git config user.email".
And see what it says. You may need to set these in order to run Git.
If I'm not mistaken it really depends on how your repo is configured.
If it's *allow everyone to clone or fork" ... then it shouldn't complain.
But if the repo is more restrictive then I can see why it may fail.

Dennis

Zeus_Dev

unread,
May 30, 2019, 4:33:47 PM5/30/19
to Vagrant
And it works like magic !  I don't understand ...


Maybe I can tell that I waited a bit longer than usual, but I can't prove it, but I stopped the execution (ctrl+c) as you can see  in the log : 

==> default: Waiting for cleanup before exiting...

And you can notice that under that line the usual line of a cms (C:\Drupal Vagrant) and then boom, those lines appears I really don't know how


So Is there any timeout or a time I don't know I need to configure, or it's just not more verbose , and it actually was cloning but i couldn't see it on the terminal (I was always checking the folder if its cloned or not but nothing on it ) 

Dennis Chang

unread,
May 31, 2019, 8:57:17 AM5/31/19
to Vagrant
Maybe it's a large repo?

But it works. Congratulations!

EL MARSSI Tarek

unread,
May 31, 2019, 9:05:59 AM5/31/19
to vagra...@googlegroups.com
Thank you Dennis ! :)

And yeah it's appx 30MB 
 And by the way, is there any way to copy-paste files from host to my VM, cuz I'm having a size importing problem with my PHPmyAdmin so I upgraded that on my Php.ini and also fixing a problem with PhpMyAdmin.

I copied pasted the modified files (php.ini / plugin_interface.lib.php) on my host maching, in mt vagrant folder, and now I want when my Ubuntu is installing , copy past those files into my guest machine :)

Le ven. 31 mai 2019 à 14:57, Dennis Chang <dennis...@gmail.com> a écrit :
Maybe it's a large repo?

But it works. Congratulations!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

Dennis Chang

unread,
May 31, 2019, 11:17:21 AM5/31/19
to Vagrant
Vagrant normally shares the current folder inside the VM as /vagrant.

So you can use that to have a file available inside your VM.

Then, in a provision.sh step, just perform the change.

In Linux/Unix there are a lot of commands available for you to perform changes to text files.
Some come to mind, sed, awk. Or if it's just copying then cp.

Zeus_Dev

unread,
May 31, 2019, 12:06:22 PM5/31/19
to Vagrant
Here is my vagrant folder :

-myVagrantProject
  |
  | -vagrantfile
  | -provision.sh
  | -php.ini
  | - plugin_interace.lib.php 
  | -myDB.sql

And this is what I want to try in my provision.sh : 

sudo cp php.ini /etc/php/7.3/apache2
sudo cp plugin_interface.lib.php /usr/share/phpmyadmin/libraries/

Dennis Chang

unread,
May 31, 2019, 12:08:31 PM5/31/19
to Vagrant
Create a dummy file in your myVagrantProject directory.
After you start up your VM, look at the /vagrant directory, do you see the dummy file there?

Zeus_Dev

unread,
May 31, 2019, 12:16:37 PM5/31/19
to Vagrant

I'll try that, but does this will not let my file shown ?

config.vm.synced_folder '.', '/var/www',
create: true,
owner: 'www-data',
group: 'www-data',
mount_options: ["dmode=775,fmode=664"]
Reply all
Reply to author
Forward
0 new messages