Skip to content

Commit aa69a87

Browse files
committed
Automated box creation
- Completed script for box building - Added default vagrant ssh keys - Added installation instructions
1 parent 49508e8 commit aa69a87

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
# Box packer configuration for Magento 2 Vagrant project
22

3-
This repository contains [Packer configuration](https://www.packer.io/docs/builders/virtualbox-ovf.html) which allows to create boxes for [Magento 2 Vagrant project](https://github.com/paliarush/magento2-vagrant-for-developers-packer)
3+
Current project allows creation of vagrant boxes for [Magento 2 Vagrant project](https://github.com/paliarush/magento2-vagrant-for-developers).
4+
Existing versions of this box can be found at the official Vagrant [box hosting](https://atlas.hashicorp.com/paliarush/boxes/magento2.ubuntu).
5+
6+
## What you get
7+
8+
**magento2.ubuntu-14.04** box based on **ubuntu/trusty64** box with software installed by [scripts/vagrant/install_magento_environment.sh](scripts/vagrant/install_magento_environment.sh).
9+
10+
## Requirements
11+
12+
- [Vagrant 1.8+](https://www.vagrantup.com/downloads.html)
13+
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
14+
- [Packer](https://www.packer.io/downloads.html)
415

516
## Usage
617

7-
1. Execute `bash build.sh`
18+
1. Execute `bash build.sh`, which will generate box in the project root
819
1. Upload created box using [Atlas Web Interface](https://atlas.hashicorp.com/help/vagrant/boxes/create)

Vagrantfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
77

88
config.vm.provider "virtualbox" do |vb|
99
vb.memory = 2048
10-
vb.name = "magento2.vagrant.packer"
10+
vb.name = "magento2.ubuntu-14.04"
1111
end
1212

1313
config.vm.provision "install_environment", type: "shell" do |s|
14-
s.path = "scripts/vagrant/install_environment.sh"
14+
s.path = "scripts/vagrant/install_magento_environment.sh"
1515
end
1616
end

build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22

3+
# Enable trace printing and exit on the first error
4+
set -ex
5+
36
vagrant up
4-
VBoxManage export magento2.vagrant.packer -o magento2.vagrant.packer.ova --ovf20
5-
vagrant destroy
7+
vagrant halt
8+
VBoxManage export -o "magento2.ubuntu-14.04.ova" --ovf20 "magento2.ubuntu-14.04"
9+
vagrant destroy -f
610
packer build template.json

scripts/packer/vagrant.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Vagrant specific
4+
date > /etc/vagrant_box_build_time
5+
6+
# Installing vagrant keys
7+
mkdir -pm 700 /home/vagrant/.ssh
8+
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
9+
chmod 0600 /home/vagrant/.ssh/authorized_keys
10+
chown -R vagrant /home/vagrant/.ssh

template.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
{
2+
"provisioners": [
3+
{
4+
"type": "shell",
5+
"scripts": [
6+
"scripts/packer/vagrant.sh"
7+
],
8+
"override": {
9+
"virtualbox-ovf": {
10+
"execute_command": "echo 'vagrant'|sudo -S bash '{{.Path}}'"
11+
}
12+
}
13+
}
14+
],
215
"builders": [
316
{
417
"type": "virtualbox-ovf",
5-
"source_path": "magento2.vagrant.packer.ova",
18+
"source_path": "magento2.ubuntu-14.04.ova",
619
"ssh_username": "vagrant",
720
"ssh_password": "vagrant",
821
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now"

0 commit comments

Comments
 (0)