Skip to content

pythianali/vagrant-lamp-puppet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant environment for testing the deployment of a LAMP stack

Table of Contents

  1. Overview
  2. Setting up the Environment
  1. Custom Configuration
  2. Bringing up the Environment
  3. TODO
  4. Development

Overview

This repository contains a Vagrantfile and code necessary to provision LAMP stack components into a testing environment, with support for various provisioners and providers.

Setting up the Environment

Requirements

  1. Operating system: Linux, Mac OS X, Windows
  2. Vagrant (TODO: determine minimum version required)
  3. Vagrant compatible hypervisor / virtualization tool. Current choices include:
  1. 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

Custom Configuration

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

Bringing up the Environment

In order to bring up the environment for the first time, it will be necessary to do the following:

  1. Ensure you have satisfied all of the requirements
  2. Clone the repository and change into the directory, if you haven't already done so
  3. 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
  4. 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.

TODO

  1. Add support for other Vagrant providers, including VMware
  2. Add support for other provisioners, including Chef and Ansible
  3. Use hiera-eyaml for secrets
  4. Make it possible to forward guest service ports to the host
  5. Resolve provisioner errors so machines are provisioned cleanly on first run

Development

If you would like to contribute to this repository, please submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 86.7%
  • Puppet 12.0%
  • Ruby 1.2%
  • Pascal 0.1%