Vagrant has been widely adopted by many and has variety of usages to streamline development and production server environments. In this article we show how to use Vagrant to provision production or development environment to our SSD Cloud VPS.
Before you begin, make sure you have
- the latest version of Vagrant installed
- running SSD Cloud VPS server
- working SSH access (username and password or SSH key available).
1. Setting up your local environment
Installing managed servers plugin for vagrant from https://github.com/tknerr/vagrant-managed-servers.
In terminal, execute:
vagrant plugin install vagrant-managed-servers
2. Configure your preferred environment in puphpet
- Make note of your operating system and make sure you use the matching one via puphpet.com
- Select "local" for the deploy target
- Select the matching Linux OS.
- Make sure Vagrant is selected as the provider.
- Navigate through the rest of of the pages and configure your web server, database server, search servers as required. The puphpet.com allows to configure SSL certificates, even rsync folders from your computer and import a database from the file stored in your folder.
- Download and extract the resulting archive to your local folder
3. Setting up Vagrantfile
In the Vagrantfile you can now use the managed provider and specify the managed server's hostname and credentials:
Vagrant.configure("2") do |config|
config.vm.box = "tknerr/managed-server-dummy"
config.vm.provider :managed do |managed, override|
managed.server = "foo.redy.host"
override.ssh.username = "bob"
override.ssh.private_key_path = "/path/to/bobs_private_key"
vagrant up --provider=managed in order to "link" the vagrant VM with the managed server:
$ vagrant up --provider=managed Bringing machine 'default' up with 'managed' provider... ==> default: Box 'tknerr/managed-server-dummy' could not be found. Attempting to find and install... default: Box Provider: managed default: Box Version: >= 0 ==> default: Loading metadata for box 'tknerr/managed-server-dummy' default: URL: https://vagrantcloud.com/tknerr/managed-server-dummy ==> default: Adding box 'tknerr/managed-server-dummy' (v1.0.0) for provider: managed default: Downloading: https://vagrantcloud.com/tknerr/managed-server-dummy/version/1/provider/managed.box default: Progress: 100% (Rate: 122k/s, Estimated time remaining: --:--:--) ==> default: Successfully added box 'tknerr/managed-server-dummy' (v1.0.0) for 'managed'! ==> default: Linking vagrant with managed server foo.redy.host ==> default: -- Server: foo.redy.host
Once linked, you can run vagrant ssh to ssh into the managed server or vagrant provision to provision that server with any of the available vagrant provisioners:
$ vagrant provision ... $ vagrant ssh ...
To reboot the managed server from the local terminal, run
When you complete configuring your server, you can "unlink" vagrant from the managed server by running
$ vagrant destroy -f ==> default: Unlinking vagrant from managed server foo.redy.host ==> default: -- Server: foo.redy.host
For other configuration options, including folders rsync (Linux and Windows), refer to the github page.