This repository contains a Vagrantfile
and code necessary to provision LAMP stack components into a testing environment, with support for various provisioners and providers.
- Operating system: Linux, Mac OS X, Windows
- Vagrant (TODO: determine minimum version required)
- Vagrant compatible hypervisor / virtualization tool. Current choices include:
- VirtualBox. Check installation instructions for your distribution.
- KVM + libvirt: for Linux systems. Check installation instructions for your distribution. You will also need the vagrant-libvirt plugin
- Google Compute Engine (GCE): for provisioning in the cloud. You will need the vagrant-google plugin
- Amazon Web Services (AWS): for provisioning in the cloud. You will need the vagrant-aws - Installs plugin. Also need to run "vagrant box add base https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" to create the base box for AMI launch.
- Vagrant plugins:
- vagrant-hostmanager - automatically add entries to
/etc/hosts
for running VMs, permitting name resolution - vagrant-puppet-install - installs Puppet inside VMs so Vagrant's Puppet provisioner may be used
- vagrant-r10k - Installs Puppet modules using r10k, rather than having to store them in the project repository
- puppet - so r10k can install modules, run
vagrant plugin install puppet
The Vagrantfile
in this repository makes use of a non-version controlled configuration file named custom.yaml
which contains your local customizations including how many instances to provision, provider settings (including project names, keys/secrets), compute resources (CPU, memory), etc.
In future it may be possible for the configuration file to be generated automatically for you, but for now you may use the following example as a starting point:
---
# Configure stack here
# ---
# Note: 'image' examples include:
# 'matjazp/ubuntu-trusty64' (libvirt)
# 'puppetlabs/ubuntu-16.04-64-nocm' (virtualbox)
# 'ami-ff427095' (AWS, https://cloud-images.ubuntu.com/locator/ec2/)
# 'ubuntu-14-04' (Google)
# Note: 'machine_type' examples include:
# 't2.micro' (AWS, http://www.ec2instances.info/)
# 'g1-small' (Google)
# ---
# Web server
webserver:
enabled: true
nodes: 1
cpus: 1
memory: 512
image: puppetlabs/ubuntu-16.04-64-nocm
machine_type: t2.micro
# Puppet provisioner settings
puppet:
version: 4.5.2
# AWS provider settings
aws:
key: # Enter your AWS key
secret: # Enter your AWS secret key
keypair: # Enter the name of your EC2 keypair
region: us-east-1
subnet_id: # Must exist
security_group: # Must exist and permit inbound SSH
associate_public_ip: true # Associate a public IP with each instance
# Google provider settings
google:
client_email: # Enter your GCE service account email
json_key_location: client_secrets.json
project_id: # Enter your GCE project ID
# Libvirt provider settings
libvirt:
nfs: false
ssh:
private_key_path: ~/.ssh/id_rsa
username: # Enter your username here
In order to bring up the environment for the first time, it will be necessary to do the following:
- Ensure you have satisfied all of the requirements
- Clone the repository and change into the directory, if you haven't already done so
- Create the
custom.yaml
file manually, using the example above if necessary. Each of the provider blocks are necessary, even if you aren't using them. Vagrant won't run if they aren't there - Create the
puppet/environments/development/vendor
directory manually.
mkdir -p puppet/environments/development/vendor
This last step is necessary since empty directories cannot be tracked in Git, and the vagrant-r10k
plugin will remove the directory's contents, making it impossible to have a placeholder file such as README.md
or .gitignore
. If you have a solution so this step is not required, please contribute :)
Once you have completed these steps, you should be able to bring up the environment by running Vagrant as follows:
vagrant up --no-parallel
If you would like to use a specific provider (such as libvirt), use the --provider
parameter:
vagrant up --provider libvirt --no-parallel
It is possible that one of the machines may fail to provision cleanly on first run. If this happens, and / or the failure prevented other machines from being brought up, you can tell Vagrant to try again using a combination of the following commands:
vagrant provision [machine]
vagrant up --provider [provider] --no-parallel
If you omit a machine name from the provision command above, Vagrant will re-run the provisioner on all available machines. There should be no cost involved in doing so, other than time.
- Add support for other Vagrant providers, including VMware
- Add support for other provisioners, including Chef and Ansible
- Use
hiera-eyaml
for secrets - Make it possible to forward guest service ports to the host
- Resolve provisioner errors so machines are provisioned cleanly on first run
If you would like to contribute to this repository, please submit a pull request.