Once all is in place you can test with vagrant destroy vagrant up
Copying files from guest to host into the /vagrant folder is good to put all into the project, you can have all in Source control. Once is done, the user experience for the new box will be git clone <url> cd <dir> vagrant up Alvaro On Sat, Sep 2, 2017 at 5:04 PM, James Newton <[email protected]> wrote: > On Wednesday, 30 August 2017 01:06:35 UTC+3, Alvaro Miranda Aguilera wrote: >> >> Please share back what you got working, so other people can learn from it. >> >> Sharing is caring :D >> > > Hi Alviro, > > The code you posted provoked errors, but it did give me a starting point > from which to work out a solution. > > # cp -ap /vagrant/nginx/* /etc/nginx/ ## should be: > cp -ap /vagrant/nginx/. /etc/nginx/ > # chkconfig nginx on > ## chkconfig is not shipped with Ubuntu since 12.04, > ## if my research is accurate. Should be: > service nginx start > > > To help others who may not be using the custom package that I have, I've > prepared a Vagrantfile that can be used after a simple `vagrant init` in > an empty folder: > > # -*- mode: ruby -*- > # vi: set ft=ruby : > > $script = <<SCRIPT > # Install nginx. > apt-get -y update > apt-get -y install nginx > service nginx start > > # Copy the nginx and www folders to the /vagrant folder, so that they > # can be synced with the host. The www and nginx folders will be > # created automatically. They don't need to exist on the host yet. > cp -ap /etc/nginx/. /vagrant/nginx/ > cp -ap /var/www/. /vagrant/www/ > > # Syncing must be done as a second step. Uncomment the lines beginning > # #*# below after the first `vagrant up`, then use `vagrant reload` > SCRIPT > > > Vagrant.configure("2") do |config| > config.vm.box = "ubuntu/xenial64" > > #Run a provisioning script on first launch > config.vm.provision "shell", inline: $script > > ## Sync the www and nginx folders, so that they can be edited on > ## the host machine. > ## Uncomment the next line only after the box has been provisioned, > ## otherwise the host's nginx/folder will overwrite the > ## guest's installation. > #*#config.vm.synced_folder 'www', '/var/www' > #*#config.vm.synced_folder 'nginx', '/etc/nginx' > > ## On the first `vagrant up`, Vagrant will automatically create a > ## /vagrant file at the root of the guest, and sync it with the > ## folder that contains this Vagrantfile. This is necessary so that > ## the command `cp -ap /etc/nginx/. /vagrant/nginx/` can copy the > ## contents of the /etc/nginx/ folder to the host. > ## > ## On subsequent launches, only the ./www/ and ./nginx/ folders need > ## to be synced, so you can uncomment the line below. > #*#config.vm.synced_folder '.', '/vagrant', disabled: true > end > > This installed nginx and copied the contents of the /etc/nginx/ and > /var/www/ directories to the host. I then manually uncommented three > lines (as shown in *bold* below) and called vagrant reload. > > # -*- mode: ruby -*- > # vi: set ft=ruby : > > $script = <<SCRIPT > # Install nginx. > apt-get -y update > apt-get -y install nginx > service nginx start > > # Copy the nginx and www folders to the /vagrant folder, so that they > # can be synced with the host. The www and nginx folders will be > # created automatically. They don't need to exist on the host yet. > cp -ap /etc/nginx/. /vagrant/nginx/ > cp -ap /var/www/. /vagrant/www/ > > # Syncing must be done as a second step. Uncomment the lines beginning > # #*# below after the first `vagrant up`, then use `vagrant reload` > SCRIPT > > > Vagrant.configure("2") do |config| > config.vm.box = "ubuntu/xenial64" > > #Run a provisioning script on first launch > config.vm.provision "shell", inline: $script > > ## Sync the www and nginx folders, so that they can be edited on > ## the host machine. > ## Uncomment the next line only after the box has been provisioned, > ## otherwise the host's nginx/folder will overwrite the > ## guest's installation. > *config* > *.vm.synced_folder 'www', '/var/www' config.vm.synced_folder 'nginx', > '/etc/nginx'* > > ## On the first `vagrant up`, Vagrant will automatically create a > ## /vagrant file at the root of the guest, and sync it with the > ## folder that contains this Vagrantfile. This is necessary so that > ## the command `cp -ap /etc/nginx/. /vagrant/nginx/` can copy the > ## contents of the /etc/nginx/ folder to the host. > ## > ## On subsequent launches, only the ./www/ and ./nginx/ folders need > ## to be synced, so you can uncomment the line below. > * config* > *.vm.synced_folder '.', '/vagrant', disabled: true*end > > It seems cumbersome to have to make these manual changes and to run > vagrant reload. Is it possible to modify this script so that the > config.vm.synced_folder calls are made only if /etc/nginx/ already > exists, and vagrant reload is called automatically if not? > > Having a single, unchanging file that gets read twice would make sharing > the Vagrant package much more straightforward. > > Thanks in advance for your ideas, > > James > > > -- > 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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/vagrant-up/565994ce-4612-4cfc-ae01-48a12983e5b2%40googlegroups.com > <https://groups.google.com/d/msgid/vagrant-up/565994ce-4612-4cfc-ae01-48a12983e5b2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Alvaro -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewPW-vXbndqFoLRyQ5mavihogmX1nR5MiSLYNnWgaZ2fg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
