├── .gitignore ├── README.md ├── example1 └── Vagrantfile ├── example2 └── Vagrantfile ├── example3 ├── Vagrantfile └── puppet │ ├── manifests │ └── site.pp │ └── modules │ └── baseconfig │ ├── files │ └── bashrc │ └── manifests │ └── init.pp ├── example4 ├── Vagrantfile ├── puppet │ ├── manifests │ │ └── site.pp │ └── modules │ │ ├── apache │ │ ├── files │ │ │ ├── apache2.conf │ │ │ ├── envvars │ │ │ └── ports.conf │ │ └── manifests │ │ │ ├── conf.pp │ │ │ └── init.pp │ │ ├── apache_vhosts │ │ ├── files │ │ │ └── static-site │ │ └── manifests │ │ │ ├── init.pp │ │ │ └── vhost.pp │ │ └── baseconfig │ │ ├── files │ │ └── bashrc │ │ └── manifests │ │ └── init.pp └── sites │ └── static-site │ ├── assets │ ├── reset.css │ └── static.css │ └── index.html ├── example5 ├── Vagrantfile ├── puppet │ ├── manifests │ │ └── site.pp │ └── modules │ │ ├── apache │ │ ├── files │ │ │ ├── apache2.conf │ │ │ ├── envvars │ │ │ └── ports.conf │ │ └── manifests │ │ │ ├── conf.pp │ │ │ ├── init.pp │ │ │ └── module.pp │ │ ├── apache_vhosts │ │ ├── files │ │ │ ├── dynamic-site │ │ │ └── static-site │ │ └── manifests │ │ │ ├── init.pp │ │ │ └── vhost.pp │ │ ├── baseconfig │ │ ├── files │ │ │ └── bashrc │ │ └── manifests │ │ │ └── init.pp │ │ ├── mysql │ │ ├── files │ │ │ └── my.cnf │ │ └── manifests │ │ │ └── init.pp │ │ └── php │ │ ├── files │ │ ├── apache2-php.ini │ │ └── cli-php.ini │ │ └── manifests │ │ └── init.pp └── sites │ ├── dynamic-site │ ├── application │ │ ├── config.php │ │ ├── models │ │ │ ├── WishListDAO.php │ │ │ └── WishListItem.php │ │ └── views │ │ │ ├── additem.php │ │ │ ├── allitems.php │ │ │ ├── edititem.php │ │ │ ├── footer.php │ │ │ └── header.php │ └── public │ │ ├── add.php │ │ ├── assets │ │ ├── dynamic.css │ │ └── reset.css │ │ ├── edit.php │ │ └── index.php │ ├── dynamic.sql │ └── static-site │ ├── assets │ ├── reset.css │ └── static.css │ └── index.html ├── example6 ├── Vagrantfile ├── puppet │ ├── manifests │ │ └── site.pp │ └── modules │ │ ├── apache │ │ ├── files │ │ │ ├── apache2.conf │ │ │ ├── envvars │ │ │ └── ports.conf │ │ └── manifests │ │ │ ├── conf.pp │ │ │ ├── init.pp │ │ │ └── module.pp │ │ ├── apache_vhosts │ │ ├── files │ │ │ ├── dynamic-site │ │ │ └── static-site │ │ └── manifests │ │ │ ├── init.pp │ │ │ └── vhost.pp │ │ ├── baseconfig │ │ ├── files │ │ │ └── bashrc │ │ └── manifests │ │ │ └── init.pp │ │ ├── lighttpd │ │ ├── files │ │ │ └── lighttpd.conf │ │ └── manifests │ │ │ ├── init.pp │ │ │ └── module.pp │ │ ├── memcache │ │ ├── files │ │ │ └── memcached.conf │ │ └── manifests │ │ │ └── init.pp │ │ ├── mysql │ │ ├── files │ │ │ └── my.cnf │ │ └── manifests │ │ │ └── init.pp │ │ ├── nginx │ │ ├── files │ │ │ ├── nginx.conf │ │ │ └── proxy_params │ │ └── manifests │ │ │ └── init.pp │ │ ├── nginx_vhosts │ │ ├── files │ │ │ ├── dynamic-site │ │ │ └── static-site │ │ └── manifests │ │ │ ├── init.pp │ │ │ └── vhost.pp │ │ └── php │ │ ├── files │ │ ├── apache2-php.ini │ │ └── cli-php.ini │ │ └── manifests │ │ └── init.pp └── sites │ ├── dynamic-site │ ├── application │ │ ├── config.php │ │ ├── models │ │ │ ├── WishListDAO.php │ │ │ └── WishListItem.php │ │ └── views │ │ │ ├── additem.php │ │ │ ├── allitems.php │ │ │ ├── edititem.php │ │ │ ├── footer.php │ │ │ └── header.php │ └── public │ │ ├── add.php │ │ ├── assets │ │ ├── dynamic.css │ │ └── reset.css │ │ ├── edit.php │ │ └── index.php │ ├── dynamic.sql │ └── static-site │ ├── assets │ ├── reset.css │ └── static.css │ └── index.html └── example7 ├── Vagrantfile ├── bootstrap.sh ├── puppet ├── manifests │ └── site.pp └── modules │ ├── apache │ ├── files │ │ ├── apache2.conf │ │ ├── envvars │ │ └── ports.conf │ └── manifests │ │ ├── conf.pp │ │ ├── init.pp │ │ └── module.pp │ ├── apache_vhosts │ ├── files │ │ ├── dynamic-site │ │ └── static-site │ └── manifests │ │ ├── init.pp │ │ └── vhost.pp │ ├── baseconfig │ ├── files │ │ └── bashrc │ └── manifests │ │ └── init.pp │ ├── mysql │ ├── files │ │ └── my.cnf │ └── manifests │ │ └── init.pp │ └── php │ ├── files │ ├── apache2-php.ini │ └── cli-php.ini │ └── manifests │ └── init.pp └── sites ├── dynamic-site ├── application │ ├── config.php │ ├── models │ │ ├── WishListDAO.php │ │ └── WishListItem.php │ └── views │ │ ├── additem.php │ │ ├── allitems.php │ │ ├── edititem.php │ │ ├── footer.php │ │ └── header.php └── public │ ├── add.php │ ├── assets │ ├── dynamic.css │ └── reset.css │ ├── edit.php │ └── index.php ├── dynamic.sql └── static-site ├── assets ├── reset.css └── static.css └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant* 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vagrant Examples 2 | 3 | ## What is Vagrant? 4 | 5 | Vagrant is a tool that uses Oracle's VirtualBox to dynamically build configurable, lightweight, and portable virtual machines. Vagrant supports the use of either Puppet or Chef for managing the configuration. Much more information is available on the [Vagrant web site](http://www.vagrantup.com). 6 | 7 | ## What is this project? 8 | 9 | This is a collection of sample Vagrant configurations using Puppet. They start out very simple with the bare minimum and gradually get more complex. The examples use Ubuntu 12.04, though they should work with any Debian-based Linux distribution. Other distros such as Fedora and SUSE could be supported with some Facter logic in the manifests to ensure that platform-specific packages are installed correctly (e.g. httpd vs apache2). 10 | 11 | ## How do I install Vagrant? 12 | 13 | The host OS used in testing these examples was Mint 14 (Ubuntu-based), but any OS should work as long as VirtualBox can be installed. The Vagrant version used in these examples is v1.1.0. The [Vagrant download page](http://downloads.vagrantup.com/tags/v1.1.0) lists several options for installing v1.1.0. 14 | 15 | ## How do I run the examples? 16 | 17 | From one of the example directories, type the following commands... 18 | 19 | ``` 20 | vagrant box add precise32 http://files.vagrantup.com/precise32.box 21 | vagrant up 22 | vagrant ssh 23 | vagrant destroy 24 | ``` 25 | 26 | These commands will bring up the Vagrant box, SSH into it, and then remove it respectively. 27 | 28 | ## Summary of examples 29 | 30 | 1. Single box with some custom configuration. 31 | 2. Single box with VirtualBox provider. 32 | 3. Single box with VirtualBox provider and Puppet provisioning. 33 | 4. Single box with Apache and sample static site installed via Puppet. 34 | 5. Separate Web and database servers serving up static/dynamic sites via Puppet. 35 | 6. Pulling out all the stops with cluster of seven Vagrant boxes. 36 | 7. Single box with AWS provider and sample static/dynamic sites via Puppet. 37 | -------------------------------------------------------------------------------- /example1/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 1 2 | # 3 | # Single box with some custom configuration. 4 | # 5 | # NOTE: Make sure you have the precise32 base box installed... 6 | # vagrant box add precise32 http://files.vagrantup.com/precise32.box 7 | 8 | Vagrant.configure("2") do |config| 9 | config.vm.box = "precise32" 10 | config.vm.hostname = "myprecise.box" 11 | config.vm.network :private_network, ip: "192.168.0.42" 12 | end 13 | -------------------------------------------------------------------------------- /example2/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 2 2 | # 3 | # Single box with VirtualBox provider. 4 | # 5 | # NOTE: Make sure you have the precise32 base box installed... 6 | # vagrant box add precise32 http://files.vagrantup.com/precise32.box 7 | # 8 | # VirtualBox modifyvm docs: http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm 9 | 10 | Vagrant.configure("2") do |config| 11 | config.vm.box = "precise32" 12 | config.vm.hostname = "myprecise.box" 13 | config.vm.network :private_network, ip: "192.168.0.42" 14 | 15 | config.vm.provider :virtualbox do |vb| 16 | vb.customize [ 17 | "modifyvm", :id, 18 | "--cpuexecutioncap", "50", 19 | "--memory", "256", 20 | ] 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /example3/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 3 2 | # 3 | # Single box with VirtualBox provider and Puppet provisioning. 4 | # 5 | # NOTE: Make sure you have the precise32 base box installed... 6 | # vagrant box add precise32 http://files.vagrantup.com/precise32.box 7 | 8 | Vagrant.configure("2") do |config| 9 | config.vm.box = "precise32" 10 | config.vm.hostname = "myprecise.box" 11 | config.vm.network :private_network, ip: "192.168.0.42" 12 | 13 | config.vm.provider :virtualbox do |vb| 14 | vb.customize [ 15 | "modifyvm", :id, 16 | "--cpuexecutioncap", "50", 17 | "--memory", "256", 18 | ] 19 | end 20 | 21 | config.vm.provision :puppet do |puppet| 22 | puppet.manifests_path = "puppet/manifests" 23 | puppet.manifest_file = "site.pp" 24 | puppet.module_path = "puppet/modules" 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /example3/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | include baseconfig 2 | 3 | -------------------------------------------------------------------------------- /example3/puppet/modules/baseconfig/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=50000 17 | HISTFILESIZE=50000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | alias ll='ls -alF' 86 | alias la='ls -A' 87 | alias l='ls -CF' 88 | 89 | # Add an "alert" alias for long running commands. Use like so: 90 | # sleep 10; alert 91 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 92 | 93 | # Alias definitions. 94 | # You may want to put all your additions into a separate file like 95 | # ~/.bash_aliases, instead of adding them here directly. 96 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 97 | 98 | if [ -f ~/.bash_aliases ]; then 99 | . ~/.bash_aliases 100 | fi 101 | 102 | # enable programmable completion features (you don't need to enable 103 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 104 | # sources /etc/bash.bashrc). 105 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 106 | . /etc/bash_completion 107 | fi 108 | -------------------------------------------------------------------------------- /example3/puppet/modules/baseconfig/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: baseconfig 2 | # 3 | # Performs initial configuration tasks for all Vagrant boxes. 4 | # 5 | class baseconfig { 6 | exec { 'apt-get update': 7 | command => '/usr/bin/apt-get update'; 8 | } 9 | 10 | host { 'hostmachine': 11 | ip => '192.168.0.1'; 12 | } 13 | 14 | package { ['htop', 'tree', 'unzip']: 15 | ensure => present; 16 | } 17 | 18 | file { 19 | '/home/vagrant/.bashrc': 20 | owner => 'vagrant', 21 | group => 'vagrant', 22 | mode => '0644', 23 | source => 'puppet:///modules/baseconfig/bashrc'; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example4/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 4 2 | # 3 | # Single box with Apache and sample static site installed via Puppet. 4 | # 5 | # NOTE: Make sure you have the precise32 base box installed... 6 | # vagrant box add precise32 http://files.vagrantup.com/precise32.box 7 | 8 | Vagrant.configure("2") do |config| 9 | config.vm.box = "precise32" 10 | config.vm.hostname = "myprecise.box" 11 | config.vm.network :private_network, ip: "192.168.0.42" 12 | 13 | config.vm.provider :virtualbox do |vb| 14 | vb.customize [ 15 | "modifyvm", :id, 16 | "--cpuexecutioncap", "50", 17 | "--memory", "256", 18 | ] 19 | end 20 | 21 | config.vm.provision :puppet do |puppet| 22 | puppet.manifests_path = "puppet/manifests" 23 | puppet.manifest_file = "site.pp" 24 | puppet.module_path = "puppet/modules" 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /example4/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # create a new run stage to ensure certain modules are included first 2 | stage { 'pre': 3 | before => Stage['main'] 4 | } 5 | 6 | # add the baseconfig module to the new 'pre' run stage 7 | class { 'baseconfig': 8 | stage => 'pre' 9 | } 10 | 11 | # set defaults for file ownership/permissions 12 | File { 13 | owner => 'root', 14 | group => 'root', 15 | mode => '0644', 16 | } 17 | 18 | include baseconfig, apache, apache_vhosts 19 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache/files/apache2.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Based upon the NCSA server configuration files originally by Rob McCool. 3 | # 4 | # This is the main Apache server configuration file. It contains the 5 | # configuration directives that give the server its instructions. 6 | # See http://httpd.apache.org/docs/2.2/ for detailed information about 7 | # the directives. 8 | # 9 | # Do NOT simply read the instructions in here without understanding 10 | # what they do. They're here only as hints or reminders. If you are unsure 11 | # consult the online docs. You have been warned. 12 | # 13 | # The configuration directives are grouped into three basic sections: 14 | # 1. Directives that control the operation of the Apache server process as a 15 | # whole (the 'global environment'). 16 | # 2. Directives that define the parameters of the 'main' or 'default' server, 17 | # which responds to requests that aren't handled by a virtual host. 18 | # These directives also provide default values for the settings 19 | # of all virtual hosts. 20 | # 3. Settings for virtual hosts, which allow Web requests to be sent to 21 | # different IP addresses or hostnames and have them handled by the 22 | # same Apache server process. 23 | # 24 | # Configuration and logfile names: If the filenames you specify for many 25 | # of the server's control files begin with "/" (or "drive:/" for Win32), the 26 | # server will use that explicit path. If the filenames do *not* begin 27 | # with "/", the value of ServerRoot is prepended -- so "foo.log" 28 | # with ServerRoot set to "/etc/apache2" will be interpreted by the 29 | # server as "/etc/apache2/foo.log". 30 | # 31 | 32 | ### Section 1: Global Environment 33 | # 34 | # The directives in this section affect the overall operation of Apache, 35 | # such as the number of concurrent requests it can handle or where it 36 | # can find its configuration files. 37 | # 38 | 39 | # 40 | # ServerRoot: The top of the directory tree under which the server's 41 | # configuration, error, and log files are kept. 42 | # 43 | # NOTE! If you intend to place this on an NFS (or otherwise network) 44 | # mounted filesystem then please read the LockFile documentation (available 45 | # at ); 46 | # you will save yourself a lot of trouble. 47 | # 48 | # Do NOT add a slash at the end of the directory path. 49 | # 50 | #ServerRoot "/etc/apache2" 51 | 52 | # 53 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 54 | # 55 | LockFile ${APACHE_LOCK_DIR}/accept.lock 56 | 57 | # 58 | # PidFile: The file in which the server should record its process 59 | # identification number when it starts. 60 | # This needs to be set in /etc/apache2/envvars 61 | # 62 | PidFile ${APACHE_PID_FILE} 63 | 64 | # 65 | # Timeout: The number of seconds before receives and sends time out. 66 | # 67 | Timeout 300 68 | 69 | # 70 | # KeepAlive: Whether or not to allow persistent connections (more than 71 | # one request per connection). Set to "Off" to deactivate. 72 | # 73 | KeepAlive On 74 | 75 | # 76 | # MaxKeepAliveRequests: The maximum number of requests to allow 77 | # during a persistent connection. Set to 0 to allow an unlimited amount. 78 | # We recommend you leave this number high, for maximum performance. 79 | # 80 | MaxKeepAliveRequests 100 81 | 82 | # 83 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 84 | # same client on the same connection. 85 | # 86 | KeepAliveTimeout 5 87 | 88 | ## 89 | ## Server-Pool Size Regulation (MPM specific) 90 | ## 91 | 92 | # prefork MPM 93 | # StartServers: number of server processes to start 94 | # MinSpareServers: minimum number of server processes which are kept spare 95 | # MaxSpareServers: maximum number of server processes which are kept spare 96 | # MaxClients: maximum number of server processes allowed to start 97 | # MaxRequestsPerChild: maximum number of requests a server process serves 98 | 99 | StartServers 5 100 | MinSpareServers 5 101 | MaxSpareServers 10 102 | MaxClients 150 103 | MaxRequestsPerChild 0 104 | 105 | 106 | # worker MPM 107 | # StartServers: initial number of server processes to start 108 | # MinSpareThreads: minimum number of worker threads which are kept spare 109 | # MaxSpareThreads: maximum number of worker threads which are kept spare 110 | # ThreadLimit: ThreadsPerChild can be changed to this maximum value during a 111 | # graceful restart. ThreadLimit can only be changed by stopping 112 | # and starting Apache. 113 | # ThreadsPerChild: constant number of worker threads in each server process 114 | # MaxClients: maximum number of simultaneous client connections 115 | # MaxRequestsPerChild: maximum number of requests a server process serves 116 | 117 | StartServers 2 118 | MinSpareThreads 25 119 | MaxSpareThreads 75 120 | ThreadLimit 64 121 | ThreadsPerChild 25 122 | MaxClients 150 123 | MaxRequestsPerChild 0 124 | 125 | 126 | # event MPM 127 | # StartServers: initial number of server processes to start 128 | # MinSpareThreads: minimum number of worker threads which are kept spare 129 | # MaxSpareThreads: maximum number of worker threads which are kept spare 130 | # ThreadsPerChild: constant number of worker threads in each server process 131 | # MaxClients: maximum number of simultaneous client connections 132 | # MaxRequestsPerChild: maximum number of requests a server process serves 133 | 134 | StartServers 2 135 | MinSpareThreads 25 136 | MaxSpareThreads 75 137 | ThreadLimit 64 138 | ThreadsPerChild 25 139 | MaxClients 150 140 | MaxRequestsPerChild 0 141 | 142 | 143 | # These need to be set in /etc/apache2/envvars 144 | User ${APACHE_RUN_USER} 145 | Group ${APACHE_RUN_GROUP} 146 | 147 | # 148 | # AccessFileName: The name of the file to look for in each directory 149 | # for additional configuration directives. See also the AllowOverride 150 | # directive. 151 | # 152 | 153 | AccessFileName .htaccess 154 | 155 | # 156 | # The following lines prevent .htaccess and .htpasswd files from being 157 | # viewed by Web clients. 158 | # 159 | 160 | Order allow,deny 161 | Deny from all 162 | Satisfy all 163 | 164 | 165 | # 166 | # DefaultType is the default MIME type the server will use for a document 167 | # if it cannot otherwise determine one, such as from filename extensions. 168 | # If your server contains mostly text or HTML documents, "text/plain" is 169 | # a good value. If most of your content is binary, such as applications 170 | # or images, you may want to use "application/octet-stream" instead to 171 | # keep browsers from trying to display binary files as though they are 172 | # text. 173 | # 174 | # It is also possible to omit any default MIME type and let the 175 | # client's browser guess an appropriate action instead. Typically the 176 | # browser will decide based on the file's extension then. In cases 177 | # where no good assumption can be made, letting the default MIME type 178 | # unset is suggested instead of forcing the browser to accept 179 | # incorrect metadata. 180 | # 181 | DefaultType None 182 | 183 | 184 | # 185 | # HostnameLookups: Log the names of clients or just their IP addresses 186 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 187 | # The default is off because it'd be overall better for the net if people 188 | # had to knowingly turn this feature on, since enabling it means that 189 | # each client request will result in AT LEAST one lookup request to the 190 | # nameserver. 191 | # 192 | HostnameLookups Off 193 | 194 | # ErrorLog: The location of the error log file. 195 | # If you do not specify an ErrorLog directive within a 196 | # container, error messages relating to that virtual host will be 197 | # logged here. If you *do* define an error logfile for a 198 | # container, that host's errors will be logged there and not here. 199 | # 200 | ErrorLog ${APACHE_LOG_DIR}/error.log 201 | 202 | # 203 | # LogLevel: Control the number of messages logged to the error_log. 204 | # Possible values include: debug, info, notice, warn, error, crit, 205 | # alert, emerg. 206 | # 207 | LogLevel warn 208 | 209 | # Include module configuration: 210 | Include mods-enabled/*.load 211 | Include mods-enabled/*.conf 212 | 213 | # Include all the user configurations: 214 | Include httpd.conf 215 | 216 | # Include ports listing 217 | Include ports.conf 218 | 219 | # 220 | # The following directives define some format nicknames for use with 221 | # a CustomLog directive (see below). 222 | # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i 223 | # 224 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 225 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 226 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 227 | LogFormat "%{Referer}i -> %U" referer 228 | LogFormat "%{User-agent}i" agent 229 | 230 | # Include of directories ignores editors' and dpkg's backup files, 231 | # see README.Debian for details. 232 | 233 | # Include generic snippets of statements 234 | Include conf.d/ 235 | 236 | # Include the virtual host configurations: 237 | Include sites-enabled/ 238 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache/files/envvars: -------------------------------------------------------------------------------- 1 | # envvars - default environment variables for apache2ctl 2 | 3 | # this won't be correct after changing uid 4 | unset HOME 5 | 6 | # for supporting multiple apache2 instances 7 | if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 8 | SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 9 | else 10 | SUFFIX= 11 | fi 12 | 13 | # Since there is no sane way to get the parsed apache2 config in scripts, some 14 | # settings are defined via environment variables and then used in apache2ctl, 15 | # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. 16 | export APACHE_RUN_USER=www-data 17 | export APACHE_RUN_GROUP=www-data 18 | export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid 19 | export APACHE_RUN_DIR=/var/run/apache2$SUFFIX 20 | export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX 21 | # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2. 22 | export APACHE_LOG_DIR=/var/log/apache2$SUFFIX 23 | 24 | ## The locale used by some modules like mod_dav 25 | export LANG=C 26 | ## Uncomment the following line to use the system default locale instead: 27 | #. /etc/default/locale 28 | 29 | export LANG 30 | 31 | ## The command to get the status for 'apache2ctl status'. 32 | ## Some packages providing 'www-browser' need '--dump' instead of '-dump'. 33 | #export APACHE_LYNX='www-browser -dump' 34 | 35 | ## If you need a higher file descriptor limit, uncomment and adjust the 36 | ## following line (default is 8192): 37 | #APACHE_ULIMIT_MAX_FILES='ulimit -n 65536' 38 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache/files/ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default 4 | # This is also true if you have upgraded from before 2.2.9-3 (i.e. from 5 | # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and 6 | # README.Debian.gz 7 | 8 | NameVirtualHost *:80 9 | Listen 80 10 | 11 | 12 | # If you add NameVirtualHost *:443 here, you will also have to change 13 | # the VirtualHost statement in /etc/apache2/sites-available/default-ssl 14 | # to 15 | # Server Name Indication for SSL named virtual hosts is currently not 16 | # supported by MSIE on Windows XP. 17 | Listen 443 18 | 19 | 20 | 21 | Listen 443 22 | 23 | 24 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache/manifests/conf.pp: -------------------------------------------------------------------------------- 1 | # == Define: conf 2 | # 3 | # Adds an Apache configuration file. 4 | # 5 | define apache::conf() { 6 | file { "/etc/apache2/${name}": 7 | source => "puppet:///modules/apache/${name}", 8 | require => Package['apache2'], 9 | notify => Service['apache2']; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache 2 | # 3 | # Installs packages for Apache and sets config files. 4 | # 5 | class apache { 6 | package { ['apache2', 'apache2-mpm-prefork']: 7 | ensure => present; 8 | } 9 | 10 | service { 'apache2': 11 | ensure => running, 12 | require => Package['apache2']; 13 | } 14 | 15 | apache::conf { ['apache2.conf', 'envvars', 'ports.conf']: } 16 | } 17 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache_vhosts/files/static-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName static-site 4 | 5 | DocumentRoot /var/www/static-site 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/static-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/static-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache_vhosts/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache_vhosts 2 | # 3 | # Adds and enables virtual hosts. Sets up /var/www symlinks. 4 | # 5 | class apache_vhosts { 6 | file { '/var/www': 7 | ensure => directory; 8 | } 9 | 10 | apache_vhosts::vhost { ['static-site']: } 11 | } 12 | -------------------------------------------------------------------------------- /example4/puppet/modules/apache_vhosts/manifests/vhost.pp: -------------------------------------------------------------------------------- 1 | # == Define: vhost 2 | # 3 | # Adds and enables an Apache virtual host 4 | # 5 | define apache_vhosts::vhost() { 6 | file { 7 | "/etc/apache2/sites-available/${name}": 8 | source => "puppet:///modules/apache_vhosts/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | 12 | "/etc/apache2/sites-enabled/${name}": 13 | ensure => link, 14 | target => "/etc/apache2/sites-available/${name}", 15 | notify => Service['apache2']; 16 | 17 | "/var/www/${name}": 18 | ensure => link, 19 | target => "/vagrant/sites/${name}"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example4/puppet/modules/baseconfig/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=50000 17 | HISTFILESIZE=50000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | alias ll='ls -alF' 86 | alias la='ls -A' 87 | alias l='ls -CF' 88 | 89 | # Add an "alert" alias for long running commands. Use like so: 90 | # sleep 10; alert 91 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 92 | 93 | # Alias definitions. 94 | # You may want to put all your additions into a separate file like 95 | # ~/.bash_aliases, instead of adding them here directly. 96 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 97 | 98 | if [ -f ~/.bash_aliases ]; then 99 | . ~/.bash_aliases 100 | fi 101 | 102 | # enable programmable completion features (you don't need to enable 103 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 104 | # sources /etc/bash.bashrc). 105 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 106 | . /etc/bash_completion 107 | fi 108 | -------------------------------------------------------------------------------- /example4/puppet/modules/baseconfig/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: baseconfig 2 | # 3 | # Performs initial configuration tasks for all Vagrant boxes. 4 | # 5 | class baseconfig { 6 | exec { 'apt-get update': 7 | command => '/usr/bin/apt-get update'; 8 | } 9 | 10 | host { 'hostmachine': 11 | ip => '192.168.0.1'; 12 | } 13 | 14 | package { ['htop', 'tree', 'unzip']: 15 | ensure => present; 16 | } 17 | 18 | file { 19 | '/home/vagrant/.bashrc': 20 | owner => 'vagrant', 21 | group => 'vagrant', 22 | mode => '0644', 23 | source => 'puppet:///modules/baseconfig/bashrc'; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example4/sites/static-site/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example4/sites/static-site/assets/static.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 10px; 8 | } 9 | 10 | #container { 11 | margin: 25px; 12 | padding: 15px; 13 | background: #FFF; 14 | border: 1px solid #444; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /example4/sites/static-site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Static Site 5 | 6 | 7 | 8 | 9 |
10 |

Static Site (Example 4)

11 |

This is an example of a static Web site configured via Puppet and Vagrant.

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /example5/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 5 2 | # 3 | # Separate Web and database servers serving up static/dynamic sites via Puppet. 4 | # 5 | # NOTE: Make sure you have the precise32 base box installed... 6 | # vagrant box add precise32 http://files.vagrantup.com/precise32.box 7 | 8 | nodes = [ 9 | { :hostname => 'ex5web', :ip => '192.168.0.42', :box => 'precise32' }, 10 | { :hostname => 'ex5db', :ip => '192.168.0.43', :box => 'precise32', :ram => 512 } 11 | ] 12 | 13 | Vagrant.configure("2") do |config| 14 | nodes.each do |node| 15 | config.vm.define node[:hostname] do |nodeconfig| 16 | nodeconfig.vm.box = "precise32" 17 | nodeconfig.vm.hostname = node[:hostname] + ".box" 18 | nodeconfig.vm.network :private_network, ip: node[:ip] 19 | 20 | memory = node[:ram] ? node[:ram] : 256; 21 | nodeconfig.vm.provider :virtualbox do |vb| 22 | vb.customize [ 23 | "modifyvm", :id, 24 | "--cpuexecutioncap", "50", 25 | "--memory", memory.to_s, 26 | ] 27 | end 28 | end 29 | end 30 | 31 | config.vm.provision :puppet do |puppet| 32 | puppet.manifests_path = "puppet/manifests" 33 | puppet.manifest_file = "site.pp" 34 | puppet.module_path = "puppet/modules" 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /example5/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # create a new run stage to ensure certain modules are included first 2 | stage { 'pre': 3 | before => Stage['main'] 4 | } 5 | 6 | # add the baseconfig module to the new 'pre' run stage 7 | class { 'baseconfig': 8 | stage => 'pre' 9 | } 10 | 11 | # set defaults for file ownership/permissions 12 | File { 13 | owner => 'root', 14 | group => 'root', 15 | mode => '0644', 16 | } 17 | 18 | # all boxes get the base config 19 | include baseconfig 20 | 21 | node 'ex5web' { 22 | include apache, apache_vhosts, php 23 | } 24 | 25 | node 'ex5db' { 26 | include mysql 27 | } 28 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/files/apache2.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Based upon the NCSA server configuration files originally by Rob McCool. 3 | # 4 | # This is the main Apache server configuration file. It contains the 5 | # configuration directives that give the server its instructions. 6 | # See http://httpd.apache.org/docs/2.2/ for detailed information about 7 | # the directives. 8 | # 9 | # Do NOT simply read the instructions in here without understanding 10 | # what they do. They're here only as hints or reminders. If you are unsure 11 | # consult the online docs. You have been warned. 12 | # 13 | # The configuration directives are grouped into three basic sections: 14 | # 1. Directives that control the operation of the Apache server process as a 15 | # whole (the 'global environment'). 16 | # 2. Directives that define the parameters of the 'main' or 'default' server, 17 | # which responds to requests that aren't handled by a virtual host. 18 | # These directives also provide default values for the settings 19 | # of all virtual hosts. 20 | # 3. Settings for virtual hosts, which allow Web requests to be sent to 21 | # different IP addresses or hostnames and have them handled by the 22 | # same Apache server process. 23 | # 24 | # Configuration and logfile names: If the filenames you specify for many 25 | # of the server's control files begin with "/" (or "drive:/" for Win32), the 26 | # server will use that explicit path. If the filenames do *not* begin 27 | # with "/", the value of ServerRoot is prepended -- so "foo.log" 28 | # with ServerRoot set to "/etc/apache2" will be interpreted by the 29 | # server as "/etc/apache2/foo.log". 30 | # 31 | 32 | ### Section 1: Global Environment 33 | # 34 | # The directives in this section affect the overall operation of Apache, 35 | # such as the number of concurrent requests it can handle or where it 36 | # can find its configuration files. 37 | # 38 | 39 | # 40 | # ServerRoot: The top of the directory tree under which the server's 41 | # configuration, error, and log files are kept. 42 | # 43 | # NOTE! If you intend to place this on an NFS (or otherwise network) 44 | # mounted filesystem then please read the LockFile documentation (available 45 | # at ); 46 | # you will save yourself a lot of trouble. 47 | # 48 | # Do NOT add a slash at the end of the directory path. 49 | # 50 | #ServerRoot "/etc/apache2" 51 | 52 | # 53 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 54 | # 55 | LockFile ${APACHE_LOCK_DIR}/accept.lock 56 | 57 | # 58 | # PidFile: The file in which the server should record its process 59 | # identification number when it starts. 60 | # This needs to be set in /etc/apache2/envvars 61 | # 62 | PidFile ${APACHE_PID_FILE} 63 | 64 | # 65 | # Timeout: The number of seconds before receives and sends time out. 66 | # 67 | Timeout 300 68 | 69 | # 70 | # KeepAlive: Whether or not to allow persistent connections (more than 71 | # one request per connection). Set to "Off" to deactivate. 72 | # 73 | KeepAlive On 74 | 75 | # 76 | # MaxKeepAliveRequests: The maximum number of requests to allow 77 | # during a persistent connection. Set to 0 to allow an unlimited amount. 78 | # We recommend you leave this number high, for maximum performance. 79 | # 80 | MaxKeepAliveRequests 100 81 | 82 | # 83 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 84 | # same client on the same connection. 85 | # 86 | KeepAliveTimeout 5 87 | 88 | ## 89 | ## Server-Pool Size Regulation (MPM specific) 90 | ## 91 | 92 | # prefork MPM 93 | # StartServers: number of server processes to start 94 | # MinSpareServers: minimum number of server processes which are kept spare 95 | # MaxSpareServers: maximum number of server processes which are kept spare 96 | # MaxClients: maximum number of server processes allowed to start 97 | # MaxRequestsPerChild: maximum number of requests a server process serves 98 | 99 | StartServers 5 100 | MinSpareServers 5 101 | MaxSpareServers 10 102 | MaxClients 150 103 | MaxRequestsPerChild 0 104 | 105 | 106 | # worker MPM 107 | # StartServers: initial number of server processes to start 108 | # MinSpareThreads: minimum number of worker threads which are kept spare 109 | # MaxSpareThreads: maximum number of worker threads which are kept spare 110 | # ThreadLimit: ThreadsPerChild can be changed to this maximum value during a 111 | # graceful restart. ThreadLimit can only be changed by stopping 112 | # and starting Apache. 113 | # ThreadsPerChild: constant number of worker threads in each server process 114 | # MaxClients: maximum number of simultaneous client connections 115 | # MaxRequestsPerChild: maximum number of requests a server process serves 116 | 117 | StartServers 2 118 | MinSpareThreads 25 119 | MaxSpareThreads 75 120 | ThreadLimit 64 121 | ThreadsPerChild 25 122 | MaxClients 150 123 | MaxRequestsPerChild 0 124 | 125 | 126 | # event MPM 127 | # StartServers: initial number of server processes to start 128 | # MinSpareThreads: minimum number of worker threads which are kept spare 129 | # MaxSpareThreads: maximum number of worker threads which are kept spare 130 | # ThreadsPerChild: constant number of worker threads in each server process 131 | # MaxClients: maximum number of simultaneous client connections 132 | # MaxRequestsPerChild: maximum number of requests a server process serves 133 | 134 | StartServers 2 135 | MinSpareThreads 25 136 | MaxSpareThreads 75 137 | ThreadLimit 64 138 | ThreadsPerChild 25 139 | MaxClients 150 140 | MaxRequestsPerChild 0 141 | 142 | 143 | # These need to be set in /etc/apache2/envvars 144 | User ${APACHE_RUN_USER} 145 | Group ${APACHE_RUN_GROUP} 146 | 147 | # 148 | # AccessFileName: The name of the file to look for in each directory 149 | # for additional configuration directives. See also the AllowOverride 150 | # directive. 151 | # 152 | 153 | AccessFileName .htaccess 154 | 155 | # 156 | # The following lines prevent .htaccess and .htpasswd files from being 157 | # viewed by Web clients. 158 | # 159 | 160 | Order allow,deny 161 | Deny from all 162 | Satisfy all 163 | 164 | 165 | # 166 | # DefaultType is the default MIME type the server will use for a document 167 | # if it cannot otherwise determine one, such as from filename extensions. 168 | # If your server contains mostly text or HTML documents, "text/plain" is 169 | # a good value. If most of your content is binary, such as applications 170 | # or images, you may want to use "application/octet-stream" instead to 171 | # keep browsers from trying to display binary files as though they are 172 | # text. 173 | # 174 | # It is also possible to omit any default MIME type and let the 175 | # client's browser guess an appropriate action instead. Typically the 176 | # browser will decide based on the file's extension then. In cases 177 | # where no good assumption can be made, letting the default MIME type 178 | # unset is suggested instead of forcing the browser to accept 179 | # incorrect metadata. 180 | # 181 | DefaultType None 182 | 183 | 184 | # 185 | # HostnameLookups: Log the names of clients or just their IP addresses 186 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 187 | # The default is off because it'd be overall better for the net if people 188 | # had to knowingly turn this feature on, since enabling it means that 189 | # each client request will result in AT LEAST one lookup request to the 190 | # nameserver. 191 | # 192 | HostnameLookups Off 193 | 194 | # ErrorLog: The location of the error log file. 195 | # If you do not specify an ErrorLog directive within a 196 | # container, error messages relating to that virtual host will be 197 | # logged here. If you *do* define an error logfile for a 198 | # container, that host's errors will be logged there and not here. 199 | # 200 | ErrorLog ${APACHE_LOG_DIR}/error.log 201 | 202 | # 203 | # LogLevel: Control the number of messages logged to the error_log. 204 | # Possible values include: debug, info, notice, warn, error, crit, 205 | # alert, emerg. 206 | # 207 | LogLevel warn 208 | 209 | # Include module configuration: 210 | Include mods-enabled/*.load 211 | Include mods-enabled/*.conf 212 | 213 | # Include all the user configurations: 214 | Include httpd.conf 215 | 216 | # Include ports listing 217 | Include ports.conf 218 | 219 | # 220 | # The following directives define some format nicknames for use with 221 | # a CustomLog directive (see below). 222 | # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i 223 | # 224 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 225 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 226 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 227 | LogFormat "%{Referer}i -> %U" referer 228 | LogFormat "%{User-agent}i" agent 229 | 230 | # Include of directories ignores editors' and dpkg's backup files, 231 | # see README.Debian for details. 232 | 233 | # Include generic snippets of statements 234 | Include conf.d/ 235 | 236 | # Include the virtual host configurations: 237 | Include sites-enabled/ 238 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/files/envvars: -------------------------------------------------------------------------------- 1 | # envvars - default environment variables for apache2ctl 2 | 3 | # this won't be correct after changing uid 4 | unset HOME 5 | 6 | # for supporting multiple apache2 instances 7 | if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 8 | SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 9 | else 10 | SUFFIX= 11 | fi 12 | 13 | # Since there is no sane way to get the parsed apache2 config in scripts, some 14 | # settings are defined via environment variables and then used in apache2ctl, 15 | # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. 16 | export APACHE_RUN_USER=www-data 17 | export APACHE_RUN_GROUP=www-data 18 | export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid 19 | export APACHE_RUN_DIR=/var/run/apache2$SUFFIX 20 | export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX 21 | # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2. 22 | export APACHE_LOG_DIR=/var/log/apache2$SUFFIX 23 | 24 | ## The locale used by some modules like mod_dav 25 | export LANG=C 26 | ## Uncomment the following line to use the system default locale instead: 27 | #. /etc/default/locale 28 | 29 | export LANG 30 | 31 | ## The command to get the status for 'apache2ctl status'. 32 | ## Some packages providing 'www-browser' need '--dump' instead of '-dump'. 33 | #export APACHE_LYNX='www-browser -dump' 34 | 35 | ## If you need a higher file descriptor limit, uncomment and adjust the 36 | ## following line (default is 8192): 37 | #APACHE_ULIMIT_MAX_FILES='ulimit -n 65536' 38 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/files/ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default 4 | # This is also true if you have upgraded from before 2.2.9-3 (i.e. from 5 | # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and 6 | # README.Debian.gz 7 | 8 | NameVirtualHost *:80 9 | Listen 80 10 | 11 | 12 | # If you add NameVirtualHost *:443 here, you will also have to change 13 | # the VirtualHost statement in /etc/apache2/sites-available/default-ssl 14 | # to 15 | # Server Name Indication for SSL named virtual hosts is currently not 16 | # supported by MSIE on Windows XP. 17 | Listen 443 18 | 19 | 20 | 21 | Listen 443 22 | 23 | 24 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/manifests/conf.pp: -------------------------------------------------------------------------------- 1 | # == Define: conf 2 | # 3 | # Adds an Apache configuration file. 4 | # 5 | define apache::conf() { 6 | file { "/etc/apache2/${name}": 7 | source => "puppet:///modules/apache/${name}", 8 | require => Package['apache2'], 9 | notify => Service['apache2']; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache 2 | # 3 | # Installs packages for Apache2, enables modules, and sets config files. 4 | # 5 | class apache { 6 | package { ['apache2', 'apache2-mpm-prefork']: 7 | ensure => present; 8 | } 9 | 10 | service { 'apache2': 11 | ensure => running, 12 | require => Package['apache2']; 13 | } 14 | 15 | apache::conf { ['apache2.conf', 'envvars', 'ports.conf']: } 16 | apache::module { ['expires.load', 'proxy.conf', 'proxy.load', 'proxy_http.load', 'rewrite.load']: } 17 | } 18 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache/manifests/module.pp: -------------------------------------------------------------------------------- 1 | # == Define: module 2 | # 3 | # Enables an Apache module. 4 | # 5 | define apache::module() { 6 | file { "/etc/apache2/mods-enabled/${name}": 7 | ensure => link, 8 | target => "/etc/apache2/mods-available/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache_vhosts/files/dynamic-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName dynamic-site 4 | 5 | DocumentRoot /var/www/dynamic-site/public 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/dynamic-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/dynamic-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache_vhosts/files/static-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName static-site 4 | 5 | DocumentRoot /var/www/static-site 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/static-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/static-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache_vhosts/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache_vhosts 2 | # 3 | # Adds and enables virtual hosts. Sets up /var/www symlinks. 4 | # 5 | class apache_vhosts { 6 | file { '/var/www': 7 | ensure => directory; 8 | } 9 | 10 | apache_vhosts::vhost { ['static-site', 'dynamic-site']: } 11 | } 12 | -------------------------------------------------------------------------------- /example5/puppet/modules/apache_vhosts/manifests/vhost.pp: -------------------------------------------------------------------------------- 1 | # == Define: vhost 2 | # 3 | # Adds and enables an Apache virtual host 4 | # 5 | define apache_vhosts::vhost() { 6 | file { 7 | "/etc/apache2/sites-available/${name}": 8 | source => "puppet:///modules/apache_vhosts/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | 12 | "/etc/apache2/sites-enabled/${name}": 13 | ensure => link, 14 | target => "/etc/apache2/sites-available/${name}", 15 | notify => Service['apache2']; 16 | 17 | "/var/www/${name}": 18 | ensure => link, 19 | target => "/vagrant/sites/${name}"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example5/puppet/modules/baseconfig/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=50000 17 | HISTFILESIZE=50000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | alias ll='ls -alF' 86 | alias la='ls -A' 87 | alias l='ls -CF' 88 | 89 | # Add an "alert" alias for long running commands. Use like so: 90 | # sleep 10; alert 91 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 92 | 93 | # Alias definitions. 94 | # You may want to put all your additions into a separate file like 95 | # ~/.bash_aliases, instead of adding them here directly. 96 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 97 | 98 | if [ -f ~/.bash_aliases ]; then 99 | . ~/.bash_aliases 100 | fi 101 | 102 | # enable programmable completion features (you don't need to enable 103 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 104 | # sources /etc/bash.bashrc). 105 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 106 | . /etc/bash_completion 107 | fi 108 | -------------------------------------------------------------------------------- /example5/puppet/modules/baseconfig/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: baseconfig 2 | # 3 | # Performs initial configuration tasks for all Vagrant boxes. 4 | # 5 | class baseconfig { 6 | exec { 'apt-get update': 7 | command => '/usr/bin/apt-get update'; 8 | } 9 | 10 | host { 11 | 'hostmachine': 12 | ip => '192.168.0.1'; 13 | 14 | 'web': 15 | ip => '192.168.0.42'; 16 | 17 | 'db': 18 | ip => '192.168.0.43'; 19 | } 20 | 21 | file { 22 | '/home/vagrant/.bashrc': 23 | owner => 'vagrant', 24 | group => 'vagrant', 25 | mode => '0644', 26 | source => 'puppet:///modules/baseconfig/bashrc'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example5/puppet/modules/mysql/files/my.cnf: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MANAGED BY PUPPET. 2 | # ANY MANUAL CHANGES WILL BE AUTOMATICALLY REVERTED. 3 | 4 | # 5 | # The MySQL database server configuration file. 6 | # 7 | # You can copy this to one of: 8 | # - "/etc/mysql/my.cnf" to set global options, 9 | # - "~/.my.cnf" to set user-specific options. 10 | # 11 | # One can use all long options that the program supports. 12 | # Run program with --help to get a list of available options and with 13 | # --print-defaults to see which it would actually understand and use. 14 | # 15 | # For explanations see 16 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 17 | 18 | # This will be passed to all mysql clients 19 | # It has been reported that passwords should be enclosed with ticks/quotes 20 | # escpecially if they contain "#" chars... 21 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 22 | [client] 23 | port = 3306 24 | socket = /var/run/mysqld/mysqld.sock 25 | 26 | # Here is entries for some specific programs 27 | # The following values assume you have at least 32M ram 28 | 29 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 30 | [mysqld_safe] 31 | socket = /var/run/mysqld/mysqld.sock 32 | nice = 0 33 | 34 | [mysqld] 35 | # 36 | # * Basic Settings 37 | # 38 | user = mysql 39 | pid-file = /var/run/mysqld/mysqld.pid 40 | socket = /var/run/mysqld/mysqld.sock 41 | port = 3306 42 | basedir = /usr 43 | datadir = /var/lib/mysql 44 | tmpdir = /tmp 45 | language = /usr/share/mysql/english 46 | skip-external-locking 47 | # 48 | # Instead of skip-networking the default is now to listen only on 49 | # localhost which is more compatible and is not less secure. 50 | #bind-address = 127.0.0.1 51 | # 52 | # * Fine Tuning 53 | # 54 | key_buffer = 16M 55 | max_allowed_packet = 16M 56 | thread_stack = 256K 57 | thread_cache_size = 8 58 | # This replaces the startup script and checks MyISAM tables if needed 59 | # the first time they are touched 60 | #myisam-recover = BACKUP 61 | #max_connections = 100 62 | #table_cache = 64 63 | #thread_concurrency = 10 64 | # 65 | # * Query Cache Configuration 66 | # 67 | query_cache_limit = 1M 68 | query_cache_size = 16M 69 | # 70 | # * Logging and Replication 71 | # 72 | # Both location gets rotated by the cronjob. 73 | # Be aware that this log type is a performance killer. 74 | #log = /var/log/mysql/mysql.log 75 | # 76 | # Error logging goes to syslog. This is a Debian improvement :) 77 | # 78 | # Here you can see queries with especially long duration 79 | #log_slow_queries = /var/log/mysql/mysql-slow.log 80 | #long_query_time = 2 81 | #log-queries-not-using-indexes 82 | # 83 | # The following can be used as easy to replay backup logs or for replication. 84 | # note: if you are setting up a replication slave, see README.Debian about 85 | # other settings you may need to change. 86 | #server-id = 1 87 | #log_bin = /var/log/mysql/mysql-bin.log 88 | expire_logs_days = 10 89 | max_binlog_size = 100M 90 | #binlog_do_db = include_database_name 91 | #binlog_ignore_db = include_database_name 92 | # 93 | # * BerkeleyDB 94 | # 95 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 96 | #skip-bdb 97 | # 98 | # * InnoDB 99 | # 100 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 101 | # Read the manual for more InnoDB related options. There are many! 102 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 103 | #skip-innodb 104 | # 105 | # * Federated 106 | # 107 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 108 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 109 | # 110 | #skip-federated 111 | # 112 | # * Security Features 113 | # 114 | # Read the manual, too, if you want chroot! 115 | # chroot = /var/lib/mysql/ 116 | # 117 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 118 | # 119 | # ssl-ca=/etc/mysql/cacert.pem 120 | # ssl-cert=/etc/mysql/server-cert.pem 121 | # ssl-key=/etc/mysql/server-key.pem 122 | 123 | 124 | 125 | [mysqldump] 126 | quick 127 | quote-names 128 | max_allowed_packet = 16M 129 | 130 | [mysql] 131 | #no-auto-rehash # faster start of mysql but no tab completition 132 | 133 | [isamchk] 134 | key_buffer = 16M 135 | 136 | # 137 | # * NDB Cluster 138 | # 139 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 140 | # 141 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 142 | # not from the NDB Management Nodes (ndb_mgmd processes). 143 | # 144 | # [MYSQL_CLUSTER] 145 | # ndb-connectstring=127.0.0.1 146 | 147 | 148 | # 149 | # * IMPORTANT: Additional settings that can override those from this file! 150 | # The files must end with '.cnf', otherwise they'll be ignored. 151 | # 152 | !includedir /etc/mysql/conf.d/ 153 | 154 | -------------------------------------------------------------------------------- /example5/puppet/modules/mysql/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: mysql 2 | # 3 | # Installs MySQL server, sets config file, and loads database for dynamic site. 4 | # 5 | class mysql { 6 | package { ['mysql-server']: 7 | ensure => present; 8 | } 9 | 10 | service { 'mysql': 11 | ensure => running, 12 | require => Package['mysql-server']; 13 | } 14 | 15 | file { '/etc/mysql/my.cnf': 16 | source => 'puppet:///modules/mysql/my.cnf', 17 | require => Package['mysql-server'], 18 | notify => Service['mysql']; 19 | } 20 | 21 | exec { 'set-mysql-password': 22 | unless => 'mysqladmin -uroot -proot status', 23 | command => "mysqladmin -uroot password root", 24 | path => ['/bin', '/usr/bin'], 25 | require => Service['mysql']; 26 | } 27 | 28 | exec { 'load-dynamic-sql': 29 | command => 'mysql -u root -proot < /vagrant/sites/dynamic.sql', 30 | path => ['/bin', '/usr/bin'], 31 | require => Exec['set-mysql-password']; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example5/puppet/modules/php/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: php 2 | # 3 | # Installs PHP5 and necessary modules. Sets config files. 4 | # 5 | class php { 6 | package { ['php5', 7 | 'php5-cli', 8 | 'libapache2-mod-php5', 9 | 'php-apc', 10 | 'php5-curl', 11 | 'php5-dev', 12 | 'php5-gd', 13 | 'php5-imagick', 14 | 'php5-mcrypt', 15 | 'php5-memcache', 16 | 'php5-mysql', 17 | 'php5-pspell', 18 | 'php5-sqlite', 19 | 'php5-tidy', 20 | 'php5-xdebug', 21 | 'php5-xmlrpc', 22 | 'php5-xsl']: 23 | ensure => present; 24 | } 25 | 26 | file { 27 | '/etc/php5/apache2': 28 | ensure => directory, 29 | before => File ['/etc/php5/apache2/php.ini']; 30 | 31 | '/etc/php5/apache2/php.ini': 32 | source => 'puppet:///modules/php/apache2-php.ini', 33 | require => Package['php5']; 34 | 35 | '/etc/php5/cli': 36 | ensure => directory, 37 | before => File ['/etc/php5/cli/php.ini']; 38 | 39 | '/etc/php5/cli/php.ini': 40 | source => 'puppet:///modules/php/cli-php.ini', 41 | require => Package['php5-cli']; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/config.php: -------------------------------------------------------------------------------- 1 | pdo = new PDO(DB_DSN, DB_USER, DB_PASS); 10 | } 11 | 12 | public function getItem($id) { 13 | $stmt = $this->pdo->prepare("SELECT * FROM WishListItem WHERE id = :id"); 14 | $stmt->execute(array(':id' => $id)); 15 | $result = $stmt->fetchAll(PDO::FETCH_CLASS, 'WishListItem'); 16 | return $result[0]; 17 | } 18 | 19 | public function getAllItems() { 20 | $query = "SELECT id, name, description FROM WishListItem ORDER BY id"; 21 | $result = $this->pdo->query($query); 22 | $result->setFetchMode(PDO::FETCH_CLASS, 'WishListItem'); 23 | return $result->fetchAll(); 24 | } 25 | 26 | public function addItem($name, $description) { 27 | $query = "INSERT INTO WishListItem (name, description) VALUES (:name, :desc)"; 28 | $params = array(':name' => $name, ':desc' => $description); 29 | $stmt = $this->pdo->prepare($query); 30 | $stmt->execute($params); 31 | } 32 | 33 | public function editItem($id, $name, $description) { 34 | $query = "UPDATE WishListItem SET name = :name, description = :desc WHERE id = :id"; 35 | $params = array(':id' => $id, ':name' => $name, ':desc' => $description); 36 | $stmt = $this->pdo->prepare($query); 37 | $stmt->execute($params); 38 | } 39 | 40 | public function deleteItem($id) { 41 | $stmt = $this->pdo->prepare("DELETE FROM WishListItem WHERE id = :id"); 42 | $stmt->execute(array(':id' => $id)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/models/WishListItem.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function getDescription() { 14 | return $this->description; 15 | } 16 | 17 | public function setId($id) { 18 | $this->id = $id; 19 | } 20 | 21 | public function getId() { 22 | return $this->id; 23 | } 24 | 25 | public function setName($name) { 26 | $this->name = $name; 27 | } 28 | 29 | public function getName() { 30 | return $this->name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/views/additem.php: -------------------------------------------------------------------------------- 1 |

Add New Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 |

14 |
15 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/views/allitems.php: -------------------------------------------------------------------------------- 1 |

Vagrant Wish List (Example 5)

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
NameDescription
editgetName() ?>getDescription() ?>
16 |

add new item

17 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/views/edititem.php: -------------------------------------------------------------------------------- 1 |

Edit Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 | 14 | 15 |

16 |
17 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/views/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/application/views/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Vagrant Wish List 5 | 6 | 7 | 8 | 9 |
10 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/public/add.php: -------------------------------------------------------------------------------- 1 | addItem($_POST['name'], $_POST['desc']); 9 | 10 | header('location: /'); 11 | exit; 12 | } 13 | 14 | require_once APPLICATION_DIR . '/views/header.php'; 15 | require_once APPLICATION_DIR . '/views/additem.php'; 16 | require_once APPLICATION_DIR . '/views/footer.php'; 17 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/public/assets/dynamic.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 15px; 8 | } 9 | 10 | p { 11 | margin-top: 12px; 12 | } 13 | 14 | input#name, input#desc { 15 | width: 300px; 16 | } 17 | 18 | input#add, input#edit, input#delete { 19 | color: #FFF; 20 | font: bold 18px Arial, sans-serif; 21 | background: #070; 22 | padding: 7px 14px; 23 | } 24 | 25 | input#delete { 26 | background: #700; 27 | } 28 | 29 | table th, table td { 30 | padding: 8px; 31 | border: 1px solid #777; 32 | } 33 | 34 | table th { 35 | background-color: #DDD; 36 | } 37 | 38 | #container { 39 | margin: 25px; 40 | padding: 15px; 41 | background-color: #FFF; 42 | border: 1px solid #444; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/public/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/public/edit.php: -------------------------------------------------------------------------------- 1 | editItem($_POST['id'], $_POST['name'], $_POST['desc']); 9 | header('location: /'); 10 | exit; 11 | } 12 | 13 | if (isset($_POST['delete'])) { 14 | $wishListDAO->deleteItem($_POST['id']); 15 | header('location: /'); 16 | exit; 17 | } 18 | 19 | $item = $wishListDAO->getItem($_GET['id']); 20 | 21 | require_once APPLICATION_DIR . '/views/header.php'; 22 | require_once APPLICATION_DIR . '/views/edititem.php'; 23 | require_once APPLICATION_DIR . '/views/footer.php'; 24 | -------------------------------------------------------------------------------- /example5/sites/dynamic-site/public/index.php: -------------------------------------------------------------------------------- 1 | getAllItems(); 7 | 8 | require_once APPLICATION_DIR . '/views/header.php'; 9 | require_once APPLICATION_DIR . '/views/allitems.php'; 10 | require_once APPLICATION_DIR . '/views/footer.php'; 11 | -------------------------------------------------------------------------------- /example5/sites/dynamic.sql: -------------------------------------------------------------------------------- 1 | -- create database for the dynamic site 2 | CREATE DATABASE IF NOT EXISTS dynamic; 3 | 4 | -- create a new user for the Web app 5 | DELETE FROM mysql.user WHERE User = 'webuser'; 6 | CREATE USER 'webuser'@'%' IDENTIFIED BY 'vagrantrocks'; 7 | 8 | -- grant only the necessary privileges to our new user 9 | GRANT SELECT, INSERT, UPDATE, DELETE ON dynamic.* TO 'webuser'@'%'; 10 | 11 | -- make this our active database 12 | USE dynamic; 13 | 14 | -- create a table to store our wish list items 15 | DROP TABLE IF EXISTS `WishListItem`; 16 | CREATE TABLE IF NOT EXISTS `WishListItem` ( 17 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 18 | `name` varchar(64) NOT NULL, 19 | `description` varchar(255), 20 | 21 | PRIMARY KEY (`id`) 22 | ) ENGINE=InnoDB; 23 | 24 | -- start with some data in the table 25 | INSERT INTO WishListItem (name, description) VALUES ('Pro Puppet book', 'I wanna be a Puppet pro.'); 26 | INSERT INTO WishListItem (name, description) VALUES ('Red Rider BB Gun', 'I will NOT shoot my eye out.'); 27 | INSERT INTO WishListItem (name, description) VALUES ('Soccer cleats', 'For ultimate frisbee. Good luck finding a size 14.'); 28 | -------------------------------------------------------------------------------- /example5/sites/static-site/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example5/sites/static-site/assets/static.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 10px; 8 | } 9 | 10 | #container { 11 | margin: 25px; 12 | padding: 15px; 13 | background: #FFF; 14 | border: 1px solid #444; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /example5/sites/static-site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Static Site 5 | 6 | 7 | 8 | 9 |
10 |

Static Site (Example 5)

11 |

This is an example of a static Web site configured via Puppet and Vagrant.

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /example6/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 6 2 | # 3 | # Pulling out all the stops with cluster of seven Vagrant boxes. 4 | # 5 | domain = 'example.com' 6 | 7 | nodes = [ 8 | { :hostname => 'ex6proxy', :ip => '192.168.0.42', :box => 'precise32' }, 9 | { :hostname => 'ex6db', :ip => '192.168.0.43', :box => 'precise32' }, 10 | { :hostname => 'ex6web1', :ip => '192.168.0.44', :box => 'precise32' }, 11 | { :hostname => 'ex6web2', :ip => '192.168.0.45', :box => 'precise32' }, 12 | { :hostname => 'ex6static1', :ip => '192.168.0.46', :box => 'precise32' }, 13 | { :hostname => 'ex6static2', :ip => '192.168.0.47', :box => 'precise32' }, 14 | { :hostname => 'ex6cache', :ip => '192.168.0.48', :box => 'precise32' }, 15 | ] 16 | 17 | Vagrant.configure("2") do |config| 18 | nodes.each do |node| 19 | config.vm.define node[:hostname] do |nodeconfig| 20 | nodeconfig.vm.box = "precise32" 21 | nodeconfig.vm.hostname = node[:hostname] + ".box" 22 | nodeconfig.vm.network :private_network, ip: node[:ip] 23 | 24 | memory = node[:ram] ? node[:ram] : 256; 25 | nodeconfig.vm.provider :virtualbox do |vb| 26 | vb.customize [ 27 | "modifyvm", :id, 28 | "--cpuexecutioncap", "50", 29 | "--memory", memory.to_s, 30 | ] 31 | end 32 | end 33 | end 34 | 35 | config.vm.provision :puppet do |puppet| 36 | puppet.manifests_path = "puppet/manifests" 37 | puppet.manifest_file = "site.pp" 38 | puppet.module_path = "puppet/modules" 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example6/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # create a new run stage to ensure certain modules are included first 2 | stage { 'pre': 3 | before => Stage['main'] 4 | } 5 | 6 | # add the baseconfig module to the new 'pre' run stage 7 | class { 'baseconfig': 8 | stage => 'pre' 9 | } 10 | 11 | # set defaults for file ownership/permissions 12 | File { 13 | owner => 'root', 14 | group => 'root', 15 | mode => '0644', 16 | } 17 | 18 | # all boxes get the base config 19 | include baseconfig 20 | 21 | node 'ex6proxy' { 22 | include nginx, nginx_vhosts 23 | } 24 | 25 | node 'ex6db' { 26 | include mysql 27 | } 28 | 29 | node 'ex6web1', 'ex6web2' { 30 | include apache, apache_vhosts, php 31 | } 32 | 33 | node 'ex6static1', 'ex6static2' { 34 | include lighttpd 35 | } 36 | 37 | node 'ex6cache' { 38 | include memcache 39 | } 40 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/files/apache2.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Based upon the NCSA server configuration files originally by Rob McCool. 3 | # 4 | # This is the main Apache server configuration file. It contains the 5 | # configuration directives that give the server its instructions. 6 | # See http://httpd.apache.org/docs/2.2/ for detailed information about 7 | # the directives. 8 | # 9 | # Do NOT simply read the instructions in here without understanding 10 | # what they do. They're here only as hints or reminders. If you are unsure 11 | # consult the online docs. You have been warned. 12 | # 13 | # The configuration directives are grouped into three basic sections: 14 | # 1. Directives that control the operation of the Apache server process as a 15 | # whole (the 'global environment'). 16 | # 2. Directives that define the parameters of the 'main' or 'default' server, 17 | # which responds to requests that aren't handled by a virtual host. 18 | # These directives also provide default values for the settings 19 | # of all virtual hosts. 20 | # 3. Settings for virtual hosts, which allow Web requests to be sent to 21 | # different IP addresses or hostnames and have them handled by the 22 | # same Apache server process. 23 | # 24 | # Configuration and logfile names: If the filenames you specify for many 25 | # of the server's control files begin with "/" (or "drive:/" for Win32), the 26 | # server will use that explicit path. If the filenames do *not* begin 27 | # with "/", the value of ServerRoot is prepended -- so "foo.log" 28 | # with ServerRoot set to "/etc/apache2" will be interpreted by the 29 | # server as "/etc/apache2/foo.log". 30 | # 31 | 32 | ### Section 1: Global Environment 33 | # 34 | # The directives in this section affect the overall operation of Apache, 35 | # such as the number of concurrent requests it can handle or where it 36 | # can find its configuration files. 37 | # 38 | 39 | # 40 | # ServerRoot: The top of the directory tree under which the server's 41 | # configuration, error, and log files are kept. 42 | # 43 | # NOTE! If you intend to place this on an NFS (or otherwise network) 44 | # mounted filesystem then please read the LockFile documentation (available 45 | # at ); 46 | # you will save yourself a lot of trouble. 47 | # 48 | # Do NOT add a slash at the end of the directory path. 49 | # 50 | #ServerRoot "/etc/apache2" 51 | 52 | # 53 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 54 | # 55 | LockFile ${APACHE_LOCK_DIR}/accept.lock 56 | 57 | # 58 | # PidFile: The file in which the server should record its process 59 | # identification number when it starts. 60 | # This needs to be set in /etc/apache2/envvars 61 | # 62 | PidFile ${APACHE_PID_FILE} 63 | 64 | # 65 | # Timeout: The number of seconds before receives and sends time out. 66 | # 67 | Timeout 300 68 | 69 | # 70 | # KeepAlive: Whether or not to allow persistent connections (more than 71 | # one request per connection). Set to "Off" to deactivate. 72 | # 73 | KeepAlive On 74 | 75 | # 76 | # MaxKeepAliveRequests: The maximum number of requests to allow 77 | # during a persistent connection. Set to 0 to allow an unlimited amount. 78 | # We recommend you leave this number high, for maximum performance. 79 | # 80 | MaxKeepAliveRequests 100 81 | 82 | # 83 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 84 | # same client on the same connection. 85 | # 86 | KeepAliveTimeout 5 87 | 88 | ## 89 | ## Server-Pool Size Regulation (MPM specific) 90 | ## 91 | 92 | # prefork MPM 93 | # StartServers: number of server processes to start 94 | # MinSpareServers: minimum number of server processes which are kept spare 95 | # MaxSpareServers: maximum number of server processes which are kept spare 96 | # MaxClients: maximum number of server processes allowed to start 97 | # MaxRequestsPerChild: maximum number of requests a server process serves 98 | 99 | StartServers 5 100 | MinSpareServers 5 101 | MaxSpareServers 10 102 | MaxClients 150 103 | MaxRequestsPerChild 0 104 | 105 | 106 | # worker MPM 107 | # StartServers: initial number of server processes to start 108 | # MinSpareThreads: minimum number of worker threads which are kept spare 109 | # MaxSpareThreads: maximum number of worker threads which are kept spare 110 | # ThreadLimit: ThreadsPerChild can be changed to this maximum value during a 111 | # graceful restart. ThreadLimit can only be changed by stopping 112 | # and starting Apache. 113 | # ThreadsPerChild: constant number of worker threads in each server process 114 | # MaxClients: maximum number of simultaneous client connections 115 | # MaxRequestsPerChild: maximum number of requests a server process serves 116 | 117 | StartServers 2 118 | MinSpareThreads 25 119 | MaxSpareThreads 75 120 | ThreadLimit 64 121 | ThreadsPerChild 25 122 | MaxClients 150 123 | MaxRequestsPerChild 0 124 | 125 | 126 | # event MPM 127 | # StartServers: initial number of server processes to start 128 | # MinSpareThreads: minimum number of worker threads which are kept spare 129 | # MaxSpareThreads: maximum number of worker threads which are kept spare 130 | # ThreadsPerChild: constant number of worker threads in each server process 131 | # MaxClients: maximum number of simultaneous client connections 132 | # MaxRequestsPerChild: maximum number of requests a server process serves 133 | 134 | StartServers 2 135 | MinSpareThreads 25 136 | MaxSpareThreads 75 137 | ThreadLimit 64 138 | ThreadsPerChild 25 139 | MaxClients 150 140 | MaxRequestsPerChild 0 141 | 142 | 143 | # These need to be set in /etc/apache2/envvars 144 | User ${APACHE_RUN_USER} 145 | Group ${APACHE_RUN_GROUP} 146 | 147 | # 148 | # AccessFileName: The name of the file to look for in each directory 149 | # for additional configuration directives. See also the AllowOverride 150 | # directive. 151 | # 152 | 153 | AccessFileName .htaccess 154 | 155 | # 156 | # The following lines prevent .htaccess and .htpasswd files from being 157 | # viewed by Web clients. 158 | # 159 | 160 | Order allow,deny 161 | Deny from all 162 | Satisfy all 163 | 164 | 165 | # 166 | # DefaultType is the default MIME type the server will use for a document 167 | # if it cannot otherwise determine one, such as from filename extensions. 168 | # If your server contains mostly text or HTML documents, "text/plain" is 169 | # a good value. If most of your content is binary, such as applications 170 | # or images, you may want to use "application/octet-stream" instead to 171 | # keep browsers from trying to display binary files as though they are 172 | # text. 173 | # 174 | # It is also possible to omit any default MIME type and let the 175 | # client's browser guess an appropriate action instead. Typically the 176 | # browser will decide based on the file's extension then. In cases 177 | # where no good assumption can be made, letting the default MIME type 178 | # unset is suggested instead of forcing the browser to accept 179 | # incorrect metadata. 180 | # 181 | DefaultType None 182 | 183 | 184 | # 185 | # HostnameLookups: Log the names of clients or just their IP addresses 186 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 187 | # The default is off because it'd be overall better for the net if people 188 | # had to knowingly turn this feature on, since enabling it means that 189 | # each client request will result in AT LEAST one lookup request to the 190 | # nameserver. 191 | # 192 | HostnameLookups Off 193 | 194 | # ErrorLog: The location of the error log file. 195 | # If you do not specify an ErrorLog directive within a 196 | # container, error messages relating to that virtual host will be 197 | # logged here. If you *do* define an error logfile for a 198 | # container, that host's errors will be logged there and not here. 199 | # 200 | ErrorLog ${APACHE_LOG_DIR}/error.log 201 | 202 | # 203 | # LogLevel: Control the number of messages logged to the error_log. 204 | # Possible values include: debug, info, notice, warn, error, crit, 205 | # alert, emerg. 206 | # 207 | LogLevel warn 208 | 209 | # Include module configuration: 210 | Include mods-enabled/*.load 211 | Include mods-enabled/*.conf 212 | 213 | # Include all the user configurations: 214 | Include httpd.conf 215 | 216 | # Include ports listing 217 | Include ports.conf 218 | 219 | # 220 | # The following directives define some format nicknames for use with 221 | # a CustomLog directive (see below). 222 | # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i 223 | # 224 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 225 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 226 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 227 | LogFormat "%{Referer}i -> %U" referer 228 | LogFormat "%{User-agent}i" agent 229 | 230 | # Include of directories ignores editors' and dpkg's backup files, 231 | # see README.Debian for details. 232 | 233 | # Include generic snippets of statements 234 | Include conf.d/ 235 | 236 | # Include the virtual host configurations: 237 | Include sites-enabled/ 238 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/files/envvars: -------------------------------------------------------------------------------- 1 | # envvars - default environment variables for apache2ctl 2 | 3 | # this won't be correct after changing uid 4 | unset HOME 5 | 6 | # for supporting multiple apache2 instances 7 | if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 8 | SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 9 | else 10 | SUFFIX= 11 | fi 12 | 13 | # Since there is no sane way to get the parsed apache2 config in scripts, some 14 | # settings are defined via environment variables and then used in apache2ctl, 15 | # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. 16 | export APACHE_RUN_USER=www-data 17 | export APACHE_RUN_GROUP=www-data 18 | export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid 19 | export APACHE_RUN_DIR=/var/run/apache2$SUFFIX 20 | export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX 21 | # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2. 22 | export APACHE_LOG_DIR=/var/log/apache2$SUFFIX 23 | 24 | ## The locale used by some modules like mod_dav 25 | export LANG=C 26 | ## Uncomment the following line to use the system default locale instead: 27 | #. /etc/default/locale 28 | 29 | export LANG 30 | 31 | ## The command to get the status for 'apache2ctl status'. 32 | ## Some packages providing 'www-browser' need '--dump' instead of '-dump'. 33 | #export APACHE_LYNX='www-browser -dump' 34 | 35 | ## If you need a higher file descriptor limit, uncomment and adjust the 36 | ## following line (default is 8192): 37 | #APACHE_ULIMIT_MAX_FILES='ulimit -n 65536' 38 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/files/ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default 4 | # This is also true if you have upgraded from before 2.2.9-3 (i.e. from 5 | # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and 6 | # README.Debian.gz 7 | 8 | NameVirtualHost *:80 9 | Listen 80 10 | 11 | 12 | # If you add NameVirtualHost *:443 here, you will also have to change 13 | # the VirtualHost statement in /etc/apache2/sites-available/default-ssl 14 | # to 15 | # Server Name Indication for SSL named virtual hosts is currently not 16 | # supported by MSIE on Windows XP. 17 | Listen 443 18 | 19 | 20 | 21 | Listen 443 22 | 23 | 24 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/manifests/conf.pp: -------------------------------------------------------------------------------- 1 | # == Define: conf 2 | # 3 | # Adds an Apache configuration file. 4 | # 5 | define apache::conf() { 6 | file { "/etc/apache2/${name}": 7 | source => "puppet:///modules/apache/${name}", 8 | require => Package['apache2'], 9 | notify => Service['apache2']; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache 2 | # 3 | # Installs packages for Apache2, enables modules, and sets config files. 4 | # 5 | class apache { 6 | package { ['apache2', 'apache2-mpm-prefork']: 7 | ensure => present; 8 | } 9 | 10 | service { 'apache2': 11 | ensure => running, 12 | require => Package['apache2']; 13 | } 14 | 15 | apache::conf { ['apache2.conf', 'envvars', 'ports.conf']: } 16 | apache::module { ['expires.load', 'proxy.conf', 'proxy.load', 'proxy_http.load', 'rewrite.load']: } 17 | } 18 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache/manifests/module.pp: -------------------------------------------------------------------------------- 1 | # == Define: module 2 | # 3 | # Enables an Apache module. 4 | # 5 | define apache::module() { 6 | file { "/etc/apache2/mods-enabled/${name}": 7 | ensure => link, 8 | target => "/etc/apache2/mods-available/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache_vhosts/files/dynamic-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName dynamic-site 4 | 5 | DocumentRoot /var/www/dynamic-site/public 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/dynamic-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/dynamic-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache_vhosts/files/static-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName static-site 4 | 5 | DocumentRoot /var/www/static-site 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/static-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/static-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache_vhosts/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache_vhosts 2 | # 3 | # Adds and enables virtual hosts. Sets up /var/www symlinks. 4 | # 5 | class apache_vhosts { 6 | file { '/var/www': 7 | ensure => directory; 8 | } 9 | 10 | apache_vhosts::vhost { ['static-site', 'dynamic-site']: } 11 | } 12 | -------------------------------------------------------------------------------- /example6/puppet/modules/apache_vhosts/manifests/vhost.pp: -------------------------------------------------------------------------------- 1 | # == Define: vhost 2 | # 3 | # Adds and enables an Apache virtual host 4 | # 5 | define apache_vhosts::vhost() { 6 | file { 7 | "/etc/apache2/sites-available/${name}": 8 | source => "puppet:///modules/apache_vhosts/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | 12 | "/etc/apache2/sites-enabled/${name}": 13 | ensure => link, 14 | target => "/etc/apache2/sites-available/${name}", 15 | notify => Service['apache2']; 16 | 17 | "/var/www/${name}": 18 | ensure => link, 19 | target => "/vagrant/sites/${name}"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example6/puppet/modules/baseconfig/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=50000 17 | HISTFILESIZE=50000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | alias ll='ls -alF' 86 | alias la='ls -A' 87 | alias l='ls -CF' 88 | 89 | # Add an "alert" alias for long running commands. Use like so: 90 | # sleep 10; alert 91 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 92 | 93 | # Alias definitions. 94 | # You may want to put all your additions into a separate file like 95 | # ~/.bash_aliases, instead of adding them here directly. 96 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 97 | 98 | if [ -f ~/.bash_aliases ]; then 99 | . ~/.bash_aliases 100 | fi 101 | 102 | # enable programmable completion features (you don't need to enable 103 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 104 | # sources /etc/bash.bashrc). 105 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 106 | . /etc/bash_completion 107 | fi 108 | -------------------------------------------------------------------------------- /example6/puppet/modules/baseconfig/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: baseconfig 2 | # 3 | # Performs initial configuration tasks for all Vagrant boxes. 4 | # 5 | class baseconfig { 6 | exec { 'apt-get update': 7 | command => '/usr/bin/apt-get update'; 8 | } 9 | 10 | host { 11 | 'hostmachine': 12 | ip => '192.168.0.1'; 13 | 14 | 'proxy': 15 | ip => '192.168.0.42'; 16 | 17 | 'db': 18 | ip => '192.168.0.43'; 19 | 20 | 'web1': 21 | ip => '192.168.0.44'; 22 | 23 | 'web2': 24 | ip => '192.168.0.45'; 25 | 26 | 'static1': 27 | ip => '192.168.0.46'; 28 | 29 | 'static2': 30 | ip => '192.168.0.47'; 31 | 32 | 'cache': 33 | ip => '192.168.0.48'; 34 | } 35 | 36 | file { 37 | '/home/vagrant/.bashrc': 38 | owner => 'vagrant', 39 | group => 'vagrant', 40 | mode => '0644', 41 | source => 'puppet:///modules/baseconfig/bashrc'; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example6/puppet/modules/lighttpd/files/lighttpd.conf: -------------------------------------------------------------------------------- 1 | server.modules = ( 2 | "mod_access", 3 | "mod_alias", 4 | "mod_compress", 5 | "mod_redirect", 6 | # "mod_rewrite", 7 | ) 8 | 9 | server.document-root = "/var/www" 10 | server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) 11 | server.errorlog = "/var/log/lighttpd/error.log" 12 | server.pid-file = "/var/run/lighttpd.pid" 13 | server.username = "www-data" 14 | server.groupname = "www-data" 15 | 16 | index-file.names = ( "index.php", "index.html", 17 | "index.htm", "default.htm", 18 | " index.lighttpd.html" ) 19 | 20 | url.access-deny = ( "~", ".inc" ) 21 | 22 | static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) 23 | 24 | ## Use ipv6 if available 25 | #include_shell "/usr/share/lighttpd/use-ipv6.pl" 26 | 27 | dir-listing.encoding = "utf-8" 28 | server.dir-listing = "enable" 29 | 30 | compress.cache-dir = "/var/cache/lighttpd/compress/" 31 | compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" ) 32 | 33 | include_shell "/usr/share/lighttpd/create-mime.assign.pl" 34 | include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 35 | 36 | ################################################################### 37 | 38 | $HTTP["host"] == "static-site" { 39 | server.document-root = "/var/www/static-site" 40 | accesslog.filename = "/var/log/lighttpd/static-site-access.log" 41 | } 42 | 43 | $HTTP["host"] == "dynamic-site" { 44 | server.document-root = "/var/www/dynamic-site" 45 | accesslog.filename = "/var/log/lighttpd/dynamic-site-access.log" 46 | } 47 | -------------------------------------------------------------------------------- /example6/puppet/modules/lighttpd/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: lighttpd 2 | # 3 | # Installs and configures Lighttpd. 4 | # 5 | class lighttpd { 6 | package { 'lighttpd': 7 | ensure => present; 8 | } 9 | 10 | service { 'lighttpd': 11 | ensure => running, 12 | require => Package['lighttpd']; 13 | } 14 | 15 | file { 16 | '/var/www': 17 | ensure => directory; 18 | 19 | '/var/www/static-site': 20 | ensure => link, 21 | target => '/vagrant/sites/static-site', 22 | require => File['/var/www']; 23 | 24 | '/var/www/dynamic-site': 25 | ensure => link, 26 | target => '/vagrant/sites/dynamic-site/public', 27 | require => File['/var/www']; 28 | 29 | '/etc/lighttpd/lighttpd.conf': 30 | source => 'puppet:///modules/lighttpd/lighttpd.conf', 31 | require => Package['lighttpd'], 32 | notify => Service['lighttpd']; 33 | } 34 | 35 | lighttpd::module { ['10-accesslog.conf']: } 36 | } 37 | -------------------------------------------------------------------------------- /example6/puppet/modules/lighttpd/manifests/module.pp: -------------------------------------------------------------------------------- 1 | # == Define: module 2 | # 3 | # Enables a Lighttpd module. 4 | # 5 | define lighttpd::module() { 6 | file { "/etc/lighttpd/conf-enabled/${name}": 7 | ensure => link, 8 | target => "/etc/lighttpd/conf-available/${name}", 9 | require => Package['lighttpd'], 10 | notify => Service['lighttpd']; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example6/puppet/modules/memcache/files/memcached.conf: -------------------------------------------------------------------------------- 1 | # memcached default config file 2 | # 2003 - Jay Bonci 3 | # This configuration file is read by the start-memcached script provided as 4 | # part of the Debian GNU/Linux distribution. 5 | 6 | # Run memcached as a daemon. This command is implied, and is not needed for the 7 | # daemon to run. See the README.Debian that comes with this package for more 8 | # information. 9 | -d 10 | 11 | # Log memcached's output to /var/log/memcached 12 | logfile /var/log/memcached.log 13 | 14 | # Be verbose 15 | # -v 16 | 17 | # Be even more verbose (print client commands as well) 18 | # -vv 19 | 20 | # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default 21 | # Note that the daemon will grow to this size, but does not start out holding this much 22 | # memory 23 | -m 64 24 | 25 | # Default connection port is 11211 26 | -p 11211 27 | 28 | # Run the daemon as root. The start-memcached will default to running as root if no 29 | # -u command is present in this config file 30 | -u memcache 31 | 32 | # Specify which IP address to listen on. The default is to listen on all IP addresses 33 | # This parameter is one of the only security measures that memcached has, so make sure 34 | # it's listening on a firewalled interface. 35 | # -l 127.0.0.1 36 | 37 | # Limit the number of simultaneous incoming connections. The daemon default is 1024 38 | # -c 1024 39 | 40 | # Lock down all paged memory. Consult with the README and homepage before you do this 41 | # -k 42 | 43 | # Return error when memory is exhausted (rather than removing items) 44 | # -M 45 | 46 | # Maximize core file limit 47 | # -r 48 | -------------------------------------------------------------------------------- /example6/puppet/modules/memcache/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: memcache 2 | # 3 | # Installs Memcached and sets config file. 4 | # 5 | class memcache { 6 | package { 'memcached': 7 | ensure => present; 8 | } 9 | 10 | service { 'memcached': 11 | ensure => running, 12 | require => Package['memcached']; 13 | } 14 | 15 | file { '/etc/memcached.conf': 16 | source => 'puppet:///modules/memcache/memcached.conf', 17 | require => Package['memcached'], 18 | notify => Service['memcached']; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example6/puppet/modules/mysql/files/my.cnf: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MANAGED BY PUPPET. 2 | # ANY MANUAL CHANGES WILL BE AUTOMATICALLY REVERTED. 3 | 4 | # 5 | # The MySQL database server configuration file. 6 | # 7 | # You can copy this to one of: 8 | # - "/etc/mysql/my.cnf" to set global options, 9 | # - "~/.my.cnf" to set user-specific options. 10 | # 11 | # One can use all long options that the program supports. 12 | # Run program with --help to get a list of available options and with 13 | # --print-defaults to see which it would actually understand and use. 14 | # 15 | # For explanations see 16 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 17 | 18 | # This will be passed to all mysql clients 19 | # It has been reported that passwords should be enclosed with ticks/quotes 20 | # escpecially if they contain "#" chars... 21 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 22 | [client] 23 | port = 3306 24 | socket = /var/run/mysqld/mysqld.sock 25 | 26 | # Here is entries for some specific programs 27 | # The following values assume you have at least 32M ram 28 | 29 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 30 | [mysqld_safe] 31 | socket = /var/run/mysqld/mysqld.sock 32 | nice = 0 33 | 34 | [mysqld] 35 | # 36 | # * Basic Settings 37 | # 38 | user = mysql 39 | pid-file = /var/run/mysqld/mysqld.pid 40 | socket = /var/run/mysqld/mysqld.sock 41 | port = 3306 42 | basedir = /usr 43 | datadir = /var/lib/mysql 44 | tmpdir = /tmp 45 | language = /usr/share/mysql/english 46 | skip-external-locking 47 | # 48 | # Instead of skip-networking the default is now to listen only on 49 | # localhost which is more compatible and is not less secure. 50 | #bind-address = 127.0.0.1 51 | # 52 | # * Fine Tuning 53 | # 54 | key_buffer = 16M 55 | max_allowed_packet = 16M 56 | thread_stack = 256K 57 | thread_cache_size = 8 58 | # This replaces the startup script and checks MyISAM tables if needed 59 | # the first time they are touched 60 | #myisam-recover = BACKUP 61 | #max_connections = 100 62 | #table_cache = 64 63 | #thread_concurrency = 10 64 | # 65 | # * Query Cache Configuration 66 | # 67 | query_cache_limit = 1M 68 | query_cache_size = 16M 69 | # 70 | # * Logging and Replication 71 | # 72 | # Both location gets rotated by the cronjob. 73 | # Be aware that this log type is a performance killer. 74 | #log = /var/log/mysql/mysql.log 75 | # 76 | # Error logging goes to syslog. This is a Debian improvement :) 77 | # 78 | # Here you can see queries with especially long duration 79 | #log_slow_queries = /var/log/mysql/mysql-slow.log 80 | #long_query_time = 2 81 | #log-queries-not-using-indexes 82 | # 83 | # The following can be used as easy to replay backup logs or for replication. 84 | # note: if you are setting up a replication slave, see README.Debian about 85 | # other settings you may need to change. 86 | #server-id = 1 87 | #log_bin = /var/log/mysql/mysql-bin.log 88 | expire_logs_days = 10 89 | max_binlog_size = 100M 90 | #binlog_do_db = include_database_name 91 | #binlog_ignore_db = include_database_name 92 | # 93 | # * BerkeleyDB 94 | # 95 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 96 | #skip-bdb 97 | # 98 | # * InnoDB 99 | # 100 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 101 | # Read the manual for more InnoDB related options. There are many! 102 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 103 | #skip-innodb 104 | # 105 | # * Federated 106 | # 107 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 108 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 109 | # 110 | #skip-federated 111 | # 112 | # * Security Features 113 | # 114 | # Read the manual, too, if you want chroot! 115 | # chroot = /var/lib/mysql/ 116 | # 117 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 118 | # 119 | # ssl-ca=/etc/mysql/cacert.pem 120 | # ssl-cert=/etc/mysql/server-cert.pem 121 | # ssl-key=/etc/mysql/server-key.pem 122 | 123 | 124 | 125 | [mysqldump] 126 | quick 127 | quote-names 128 | max_allowed_packet = 16M 129 | 130 | [mysql] 131 | #no-auto-rehash # faster start of mysql but no tab completition 132 | 133 | [isamchk] 134 | key_buffer = 16M 135 | 136 | # 137 | # * NDB Cluster 138 | # 139 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 140 | # 141 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 142 | # not from the NDB Management Nodes (ndb_mgmd processes). 143 | # 144 | # [MYSQL_CLUSTER] 145 | # ndb-connectstring=127.0.0.1 146 | 147 | 148 | # 149 | # * IMPORTANT: Additional settings that can override those from this file! 150 | # The files must end with '.cnf', otherwise they'll be ignored. 151 | # 152 | !includedir /etc/mysql/conf.d/ 153 | 154 | -------------------------------------------------------------------------------- /example6/puppet/modules/mysql/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: mysql 2 | # 3 | # Installs MySQL server, sets config file, and loads database for dynamic site. 4 | # 5 | class mysql { 6 | package { ['mysql-server']: 7 | ensure => present; 8 | } 9 | 10 | service { 'mysql': 11 | ensure => running, 12 | require => Package['mysql-server']; 13 | } 14 | 15 | file { '/etc/mysql/my.cnf': 16 | source => 'puppet:///modules/mysql/my.cnf', 17 | require => Package['mysql-server'], 18 | notify => Service['mysql']; 19 | } 20 | 21 | exec { 'set-mysql-password': 22 | unless => 'mysqladmin -uroot -proot status', 23 | command => "mysqladmin -uroot password root", 24 | path => ['/bin', '/usr/bin'], 25 | require => Service['mysql']; 26 | } 27 | 28 | exec { 'load-dynamic-sql': 29 | command => 'mysql -u root -proot < /vagrant/sites/dynamic.sql', 30 | path => ['/bin', '/usr/bin'], 31 | require => Exec['set-mysql-password']; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx/files/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes 4; 3 | pid /var/run/nginx.pid; 4 | 5 | events { 6 | worker_connections 768; 7 | # multi_accept on; 8 | } 9 | 10 | http { 11 | 12 | ## 13 | # Basic Settings 14 | ## 15 | 16 | sendfile on; 17 | tcp_nopush on; 18 | tcp_nodelay on; 19 | keepalive_timeout 65; 20 | types_hash_max_size 2048; 21 | # server_tokens off; 22 | 23 | # server_names_hash_bucket_size 64; 24 | # server_name_in_redirect off; 25 | 26 | include /etc/nginx/mime.types; 27 | default_type application/octet-stream; 28 | 29 | ## 30 | # Logging Settings 31 | ## 32 | 33 | access_log /var/log/nginx/access.log; 34 | error_log /var/log/nginx/error.log; 35 | 36 | ## 37 | # Gzip Settings 38 | ## 39 | 40 | gzip on; 41 | gzip_disable "msie6"; 42 | 43 | # gzip_vary on; 44 | # gzip_proxied any; 45 | # gzip_comp_level 6; 46 | # gzip_buffers 16 8k; 47 | # gzip_http_version 1.1; 48 | # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 49 | 50 | ## 51 | # Virtual Host Configs 52 | ## 53 | 54 | include /etc/nginx/conf.d/*.conf; 55 | include /etc/nginx/sites-enabled/*; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx/files/proxy_params: -------------------------------------------------------------------------------- 1 | proxy_set_header Host $host; 2 | proxy_set_header X-Real-IP $remote_addr; 3 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 4 | 5 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: nginx 2 | # 3 | # Installs and configures Nginx. 4 | # 5 | class nginx { 6 | package { 'nginx': 7 | ensure => present; 8 | } 9 | 10 | service { 'nginx': 11 | ensure => running, 12 | require => Package['nginx']; 13 | } 14 | 15 | file { 16 | '/etc/nginx/nginx.conf': 17 | ensure => present, 18 | source => 'puppet:///modules/nginx/nginx.conf', 19 | require => Package['nginx'], 20 | notify => Service['nginx']; 21 | 22 | '/etc/nginx/proxy_params': 23 | ensure => present, 24 | source => 'puppet:///modules/nginx/proxy_params', 25 | require => Package['nginx'], 26 | notify => Service['nginx']; 27 | 28 | '/etc/nginx/sites-enabled/default': 29 | ensure => absent, 30 | require => Package['nginx'], 31 | notify => Service['nginx']; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx_vhosts/files/dynamic-site: -------------------------------------------------------------------------------- 1 | upstream dynamic_web_cluster { 2 | server web1:80; 3 | server web2:80; 4 | } 5 | 6 | upstream dynamic_asset_cluster { 7 | server static1:80; 8 | server static2:80; 9 | } 10 | 11 | server { 12 | listen 80; 13 | server_name dynamic-site; 14 | 15 | location /assets/ { 16 | proxy_pass http://dynamic_asset_cluster; 17 | include /etc/nginx/proxy_params; 18 | } 19 | 20 | location / { 21 | proxy_pass http://dynamic_web_cluster; 22 | include /etc/nginx/proxy_params; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx_vhosts/files/static-site: -------------------------------------------------------------------------------- 1 | upstream static_web_cluster { 2 | server web1:80; 3 | server web2:80; 4 | } 5 | 6 | upstream static_asset_cluster { 7 | server static1:80; 8 | server static2:80; 9 | } 10 | 11 | server { 12 | listen 80; 13 | server_name static-site; 14 | 15 | location /assets/ { 16 | proxy_pass http://static_asset_cluster; 17 | include /etc/nginx/proxy_params; 18 | } 19 | 20 | location / { 21 | proxy_pass http://static_web_cluster; 22 | include /etc/nginx/proxy_params; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx_vhosts/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: nginx_vhosts 2 | # 3 | # Adds and enables virtual hosts. 4 | # 5 | class nginx_vhosts { 6 | nginx_vhosts::vhost { ['static-site', 'dynamic-site']: } 7 | } 8 | -------------------------------------------------------------------------------- /example6/puppet/modules/nginx_vhosts/manifests/vhost.pp: -------------------------------------------------------------------------------- 1 | # == Define: vhost 2 | # 3 | # Adds and enables an Nginx virtual host 4 | # 5 | define nginx_vhosts::vhost() { 6 | file { 7 | "/etc/nginx/sites-available/${name}": 8 | ensure => present, 9 | source => "puppet:///modules/nginx_vhosts/${name}", 10 | require => Package['nginx'], 11 | notify => Service['nginx']; 12 | 13 | "/etc/nginx/sites-enabled/${name}": 14 | ensure => link, 15 | target => "/etc/nginx/sites-available/${name}", 16 | require => Package['nginx'], 17 | notify => Service['nginx']; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example6/puppet/modules/php/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: php 2 | # 3 | # Installs PHP5 and necessary modules. Sets config files. 4 | # 5 | class php { 6 | package { ['php5', 7 | 'php5-cli', 8 | 'libapache2-mod-php5', 9 | 'php-apc', 10 | 'php5-curl', 11 | 'php5-dev', 12 | 'php5-gd', 13 | 'php5-imagick', 14 | 'php5-mcrypt', 15 | 'php5-memcache', 16 | 'php5-mysql', 17 | 'php5-pspell', 18 | 'php5-sqlite', 19 | 'php5-tidy', 20 | 'php5-xdebug', 21 | 'php5-xmlrpc', 22 | 'php5-xsl']: 23 | ensure => present; 24 | } 25 | 26 | file { 27 | '/etc/php5/apache2': 28 | ensure => directory, 29 | before => File ['/etc/php5/apache2/php.ini']; 30 | 31 | '/etc/php5/apache2/php.ini': 32 | source => 'puppet:///modules/php/apache2-php.ini', 33 | require => Package['php5']; 34 | 35 | '/etc/php5/cli': 36 | ensure => directory, 37 | before => File ['/etc/php5/cli/php.ini']; 38 | 39 | '/etc/php5/cli/php.ini': 40 | source => 'puppet:///modules/php/cli-php.ini', 41 | require => Package['php5-cli']; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/config.php: -------------------------------------------------------------------------------- 1 | pdo = new PDO(DB_DSN, DB_USER, DB_PASS); 15 | 16 | // establish connection to Memcache 17 | $this->memcache = new Memcache(); 18 | $this->memcache->connect(CACHE_HOST, CACHE_PORT); 19 | } 20 | 21 | public function getItem($id) { 22 | $stmt = $this->pdo->prepare("SELECT * FROM WishListItem WHERE id = :id"); 23 | $stmt->execute(array(':id' => $id)); 24 | $result = $stmt->fetchAll(PDO::FETCH_CLASS, 'WishListItem'); 25 | return $result[0]; 26 | } 27 | 28 | public function getAllItems() { 29 | // check if the items are in Memcache 30 | $items = $this->memcache->get(self::ALL_ITEMS_KEY); 31 | if (is_array($items)) { 32 | return $items; 33 | } 34 | 35 | // fetch the items from the database 36 | $query = "SELECT id, name, description FROM WishListItem ORDER BY id"; 37 | $result = $this->pdo->query($query); 38 | $result->setFetchMode(PDO::FETCH_CLASS, 'WishListItem'); 39 | $items = $result->fetchAll(); 40 | 41 | // store the items in Memcache for a short time 42 | $this->memcache->set(self::ALL_ITEMS_KEY, $items, MEMCACHE_COMPRESSED, self::CACHE_LIFETIME); 43 | 44 | return $items; 45 | } 46 | 47 | public function addItem($name, $description) { 48 | $query = "INSERT INTO WishListItem (name, description) VALUES (:name, :desc)"; 49 | $params = array(':name' => $name, ':desc' => $description); 50 | $stmt = $this->pdo->prepare($query); 51 | $stmt->execute($params); 52 | } 53 | 54 | public function editItem($id, $name, $description) { 55 | $query = "UPDATE WishListItem SET name = :name, description = :desc WHERE id = :id"; 56 | $params = array(':id' => $id, ':name' => $name, ':desc' => $description); 57 | $stmt = $this->pdo->prepare($query); 58 | $stmt->execute($params); 59 | } 60 | 61 | public function deleteItem($id) { 62 | $stmt = $this->pdo->prepare("DELETE FROM WishListItem WHERE id = :id"); 63 | $stmt->execute(array(':id' => $id)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/models/WishListItem.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function getDescription() { 14 | return $this->description; 15 | } 16 | 17 | public function setId($id) { 18 | $this->id = $id; 19 | } 20 | 21 | public function getId() { 22 | return $this->id; 23 | } 24 | 25 | public function setName($name) { 26 | $this->name = $name; 27 | } 28 | 29 | public function getName() { 30 | return $this->name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/views/additem.php: -------------------------------------------------------------------------------- 1 |

Add New Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 |

14 |
15 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/views/allitems.php: -------------------------------------------------------------------------------- 1 |

Vagrant Wish List (Example 6)

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
NameDescription
editgetName() ?>getDescription() ?>
16 |

add new item

17 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/views/edititem.php: -------------------------------------------------------------------------------- 1 |

Edit Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 | 14 | 15 |

16 |
17 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/views/footer.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/application/views/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Vagrant Wish List 5 | 6 | 7 | 8 | 9 |
10 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/public/add.php: -------------------------------------------------------------------------------- 1 | addItem($_POST['name'], $_POST['desc']); 9 | 10 | header('location: /'); 11 | exit; 12 | } 13 | 14 | require_once APPLICATION_DIR . '/views/header.php'; 15 | require_once APPLICATION_DIR . '/views/additem.php'; 16 | require_once APPLICATION_DIR . '/views/footer.php'; 17 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/public/assets/dynamic.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 15px; 8 | } 9 | 10 | p { 11 | margin-top: 12px; 12 | } 13 | 14 | input#name, input#desc { 15 | width: 300px; 16 | } 17 | 18 | input#add, input#edit, input#delete { 19 | color: #FFF; 20 | font: bold 18px Arial, sans-serif; 21 | background: #070; 22 | padding: 7px 14px; 23 | } 24 | 25 | input#delete { 26 | background: #700; 27 | } 28 | 29 | table th, table td { 30 | padding: 8px; 31 | border: 1px solid #777; 32 | } 33 | 34 | table th { 35 | background-color: #DDD; 36 | } 37 | 38 | #container { 39 | margin: 25px; 40 | padding: 15px; 41 | background-color: #FFF; 42 | border: 1px solid #444; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/public/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/public/edit.php: -------------------------------------------------------------------------------- 1 | editItem($_POST['id'], $_POST['name'], $_POST['desc']); 9 | header('location: /'); 10 | exit; 11 | } 12 | 13 | if (isset($_POST['delete'])) { 14 | $wishListDAO->deleteItem($_POST['id']); 15 | header('location: /'); 16 | exit; 17 | } 18 | 19 | $item = $wishListDAO->getItem($_GET['id']); 20 | 21 | require_once APPLICATION_DIR . '/views/header.php'; 22 | require_once APPLICATION_DIR . '/views/edititem.php'; 23 | require_once APPLICATION_DIR . '/views/footer.php'; 24 | -------------------------------------------------------------------------------- /example6/sites/dynamic-site/public/index.php: -------------------------------------------------------------------------------- 1 | getAllItems(); 7 | 8 | require_once APPLICATION_DIR . '/views/header.php'; 9 | require_once APPLICATION_DIR . '/views/allitems.php'; 10 | require_once APPLICATION_DIR . '/views/footer.php'; 11 | -------------------------------------------------------------------------------- /example6/sites/dynamic.sql: -------------------------------------------------------------------------------- 1 | -- create database for the dynamic site 2 | CREATE DATABASE IF NOT EXISTS dynamic; 3 | 4 | -- create a new user for the Web app 5 | DELETE FROM mysql.user WHERE User = 'webuser'; 6 | CREATE USER 'webuser'@'%' IDENTIFIED BY 'vagrantrocks'; 7 | 8 | -- grant only the necessary privileges to our new user 9 | GRANT SELECT, INSERT, UPDATE, DELETE ON dynamic.* TO 'webuser'@'%'; 10 | 11 | -- make this our active database 12 | USE dynamic; 13 | 14 | -- create a table to store our wish list items 15 | DROP TABLE IF EXISTS `WishListItem`; 16 | CREATE TABLE IF NOT EXISTS `WishListItem` ( 17 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 18 | `name` varchar(64) NOT NULL, 19 | `description` varchar(255), 20 | 21 | PRIMARY KEY (`id`) 22 | ) ENGINE=InnoDB; 23 | 24 | -- start with some data in the table 25 | INSERT INTO WishListItem (name, description) VALUES ('Pro Puppet book', 'I wanna be a Puppet pro.'); 26 | INSERT INTO WishListItem (name, description) VALUES ('Red Rider BB Gun', 'I will NOT shoot my eye out.'); 27 | INSERT INTO WishListItem (name, description) VALUES ('Soccer cleats', 'For ultimate frisbee. Good luck finding a size 14.'); 28 | -------------------------------------------------------------------------------- /example6/sites/static-site/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example6/sites/static-site/assets/static.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 10px; 8 | } 9 | 10 | #container { 11 | margin: 25px; 12 | padding: 15px; 13 | background: #FFF; 14 | border: 1px solid #444; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /example6/sites/static-site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Static Site 5 | 6 | 7 | 8 | 9 |
10 |

Static Site (Example 6)

11 |

This is an example of a static Web site configured via Puppet and Vagrant.

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /example7/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Example 7 2 | # 3 | # Single box with AWS provider and sample static/dynamic sites via Puppet. 4 | # 5 | # NOTE: Make sure you install the Vagrant AWS plugin... 6 | # vagrant plugin install vagrant-aws 7 | # 8 | # Make sure you add the following dummy box... 9 | # vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box 10 | # 11 | # Also add a new security group in the EC2 us-west-2 region called "vagrant" 12 | # and open ports 22 and 80 to all inbound traffic. 13 | # 14 | # Use the following command to spin up the box... 15 | # vagrant up --provider=aws 16 | 17 | Vagrant.configure("2") do |config| 18 | config.vm.box = "dummy" 19 | config.ssh.username = "ubuntu" 20 | 21 | config.vm.provider :aws do |aws| 22 | aws.access_key_id = "YOUR_ACCESS_KEY_ID" 23 | aws.secret_access_key = "YOUR_SECRET_ACCESS_KEY" 24 | aws.keypair_name = "YOUR_KEYPAIR_NAME" 25 | aws.ssh_private_key_path = "PATH_TO_YOUR_PRIVATE_KEY" 26 | 27 | aws.ssh_username = "ubuntu" 28 | aws.region = "us-west-2" 29 | aws.ami = "ami-4ad94c7a" 30 | aws.instance_type = "t1.micro" 31 | aws.security_groups = [ "vagrant" ] 32 | 33 | aws.tags = { 34 | Name: "Vagrant AWS" 35 | } 36 | end 37 | 38 | config.vm.provision :shell, :path => "bootstrap.sh" 39 | 40 | config.vm.provision :puppet do |puppet| 41 | puppet.manifests_path = "puppet/manifests" 42 | puppet.manifest_file = "site.pp" 43 | puppet.module_path = "puppet/modules" 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /example7/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get --yes update 4 | sudo apt-get --yes upgrade 5 | sudo apt-get --yes install puppet 6 | -------------------------------------------------------------------------------- /example7/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # create a new run stage to ensure certain modules are included first 2 | stage { 'pre': 3 | before => Stage['main'] 4 | } 5 | 6 | # add the baseconfig module to the new 'pre' run stage 7 | class { 'baseconfig': 8 | stage => 'pre' 9 | } 10 | 11 | # set defaults for file ownership/permissions 12 | File { 13 | owner => 'root', 14 | group => 'root', 15 | mode => '0644', 16 | } 17 | 18 | include baseconfig, apache, mysql, php, apache_vhosts 19 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/files/apache2.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Based upon the NCSA server configuration files originally by Rob McCool. 3 | # 4 | # This is the main Apache server configuration file. It contains the 5 | # configuration directives that give the server its instructions. 6 | # See http://httpd.apache.org/docs/2.2/ for detailed information about 7 | # the directives. 8 | # 9 | # Do NOT simply read the instructions in here without understanding 10 | # what they do. They're here only as hints or reminders. If you are unsure 11 | # consult the online docs. You have been warned. 12 | # 13 | # The configuration directives are grouped into three basic sections: 14 | # 1. Directives that control the operation of the Apache server process as a 15 | # whole (the 'global environment'). 16 | # 2. Directives that define the parameters of the 'main' or 'default' server, 17 | # which responds to requests that aren't handled by a virtual host. 18 | # These directives also provide default values for the settings 19 | # of all virtual hosts. 20 | # 3. Settings for virtual hosts, which allow Web requests to be sent to 21 | # different IP addresses or hostnames and have them handled by the 22 | # same Apache server process. 23 | # 24 | # Configuration and logfile names: If the filenames you specify for many 25 | # of the server's control files begin with "/" (or "drive:/" for Win32), the 26 | # server will use that explicit path. If the filenames do *not* begin 27 | # with "/", the value of ServerRoot is prepended -- so "foo.log" 28 | # with ServerRoot set to "/etc/apache2" will be interpreted by the 29 | # server as "/etc/apache2/foo.log". 30 | # 31 | 32 | ### Section 1: Global Environment 33 | # 34 | # The directives in this section affect the overall operation of Apache, 35 | # such as the number of concurrent requests it can handle or where it 36 | # can find its configuration files. 37 | # 38 | 39 | # 40 | # ServerRoot: The top of the directory tree under which the server's 41 | # configuration, error, and log files are kept. 42 | # 43 | # NOTE! If you intend to place this on an NFS (or otherwise network) 44 | # mounted filesystem then please read the LockFile documentation (available 45 | # at ); 46 | # you will save yourself a lot of trouble. 47 | # 48 | # Do NOT add a slash at the end of the directory path. 49 | # 50 | #ServerRoot "/etc/apache2" 51 | 52 | # 53 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 54 | # 55 | LockFile ${APACHE_LOCK_DIR}/accept.lock 56 | 57 | # 58 | # PidFile: The file in which the server should record its process 59 | # identification number when it starts. 60 | # This needs to be set in /etc/apache2/envvars 61 | # 62 | PidFile ${APACHE_PID_FILE} 63 | 64 | # 65 | # Timeout: The number of seconds before receives and sends time out. 66 | # 67 | Timeout 300 68 | 69 | # 70 | # KeepAlive: Whether or not to allow persistent connections (more than 71 | # one request per connection). Set to "Off" to deactivate. 72 | # 73 | KeepAlive On 74 | 75 | # 76 | # MaxKeepAliveRequests: The maximum number of requests to allow 77 | # during a persistent connection. Set to 0 to allow an unlimited amount. 78 | # We recommend you leave this number high, for maximum performance. 79 | # 80 | MaxKeepAliveRequests 100 81 | 82 | # 83 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 84 | # same client on the same connection. 85 | # 86 | KeepAliveTimeout 5 87 | 88 | ## 89 | ## Server-Pool Size Regulation (MPM specific) 90 | ## 91 | 92 | # prefork MPM 93 | # StartServers: number of server processes to start 94 | # MinSpareServers: minimum number of server processes which are kept spare 95 | # MaxSpareServers: maximum number of server processes which are kept spare 96 | # MaxClients: maximum number of server processes allowed to start 97 | # MaxRequestsPerChild: maximum number of requests a server process serves 98 | 99 | StartServers 5 100 | MinSpareServers 5 101 | MaxSpareServers 10 102 | MaxClients 150 103 | MaxRequestsPerChild 0 104 | 105 | 106 | # worker MPM 107 | # StartServers: initial number of server processes to start 108 | # MinSpareThreads: minimum number of worker threads which are kept spare 109 | # MaxSpareThreads: maximum number of worker threads which are kept spare 110 | # ThreadLimit: ThreadsPerChild can be changed to this maximum value during a 111 | # graceful restart. ThreadLimit can only be changed by stopping 112 | # and starting Apache. 113 | # ThreadsPerChild: constant number of worker threads in each server process 114 | # MaxClients: maximum number of simultaneous client connections 115 | # MaxRequestsPerChild: maximum number of requests a server process serves 116 | 117 | StartServers 2 118 | MinSpareThreads 25 119 | MaxSpareThreads 75 120 | ThreadLimit 64 121 | ThreadsPerChild 25 122 | MaxClients 150 123 | MaxRequestsPerChild 0 124 | 125 | 126 | # event MPM 127 | # StartServers: initial number of server processes to start 128 | # MinSpareThreads: minimum number of worker threads which are kept spare 129 | # MaxSpareThreads: maximum number of worker threads which are kept spare 130 | # ThreadsPerChild: constant number of worker threads in each server process 131 | # MaxClients: maximum number of simultaneous client connections 132 | # MaxRequestsPerChild: maximum number of requests a server process serves 133 | 134 | StartServers 2 135 | MinSpareThreads 25 136 | MaxSpareThreads 75 137 | ThreadLimit 64 138 | ThreadsPerChild 25 139 | MaxClients 150 140 | MaxRequestsPerChild 0 141 | 142 | 143 | # These need to be set in /etc/apache2/envvars 144 | User ${APACHE_RUN_USER} 145 | Group ${APACHE_RUN_GROUP} 146 | 147 | # 148 | # AccessFileName: The name of the file to look for in each directory 149 | # for additional configuration directives. See also the AllowOverride 150 | # directive. 151 | # 152 | 153 | AccessFileName .htaccess 154 | 155 | # 156 | # The following lines prevent .htaccess and .htpasswd files from being 157 | # viewed by Web clients. 158 | # 159 | 160 | Order allow,deny 161 | Deny from all 162 | Satisfy all 163 | 164 | 165 | # 166 | # DefaultType is the default MIME type the server will use for a document 167 | # if it cannot otherwise determine one, such as from filename extensions. 168 | # If your server contains mostly text or HTML documents, "text/plain" is 169 | # a good value. If most of your content is binary, such as applications 170 | # or images, you may want to use "application/octet-stream" instead to 171 | # keep browsers from trying to display binary files as though they are 172 | # text. 173 | # 174 | # It is also possible to omit any default MIME type and let the 175 | # client's browser guess an appropriate action instead. Typically the 176 | # browser will decide based on the file's extension then. In cases 177 | # where no good assumption can be made, letting the default MIME type 178 | # unset is suggested instead of forcing the browser to accept 179 | # incorrect metadata. 180 | # 181 | DefaultType None 182 | 183 | 184 | # 185 | # HostnameLookups: Log the names of clients or just their IP addresses 186 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 187 | # The default is off because it'd be overall better for the net if people 188 | # had to knowingly turn this feature on, since enabling it means that 189 | # each client request will result in AT LEAST one lookup request to the 190 | # nameserver. 191 | # 192 | HostnameLookups Off 193 | 194 | # ErrorLog: The location of the error log file. 195 | # If you do not specify an ErrorLog directive within a 196 | # container, error messages relating to that virtual host will be 197 | # logged here. If you *do* define an error logfile for a 198 | # container, that host's errors will be logged there and not here. 199 | # 200 | ErrorLog ${APACHE_LOG_DIR}/error.log 201 | 202 | # 203 | # LogLevel: Control the number of messages logged to the error_log. 204 | # Possible values include: debug, info, notice, warn, error, crit, 205 | # alert, emerg. 206 | # 207 | LogLevel warn 208 | 209 | # Include module configuration: 210 | Include mods-enabled/*.load 211 | Include mods-enabled/*.conf 212 | 213 | # Include all the user configurations: 214 | Include httpd.conf 215 | 216 | # Include ports listing 217 | Include ports.conf 218 | 219 | # 220 | # The following directives define some format nicknames for use with 221 | # a CustomLog directive (see below). 222 | # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i 223 | # 224 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 225 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 226 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 227 | LogFormat "%{Referer}i -> %U" referer 228 | LogFormat "%{User-agent}i" agent 229 | 230 | # Include of directories ignores editors' and dpkg's backup files, 231 | # see README.Debian for details. 232 | 233 | # Include generic snippets of statements 234 | Include conf.d/ 235 | 236 | # Include the virtual host configurations: 237 | Include sites-enabled/ 238 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/files/envvars: -------------------------------------------------------------------------------- 1 | # envvars - default environment variables for apache2ctl 2 | 3 | # this won't be correct after changing uid 4 | unset HOME 5 | 6 | # for supporting multiple apache2 instances 7 | if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 8 | SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 9 | else 10 | SUFFIX= 11 | fi 12 | 13 | # Since there is no sane way to get the parsed apache2 config in scripts, some 14 | # settings are defined via environment variables and then used in apache2ctl, 15 | # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. 16 | export APACHE_RUN_USER=www-data 17 | export APACHE_RUN_GROUP=www-data 18 | export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid 19 | export APACHE_RUN_DIR=/var/run/apache2$SUFFIX 20 | export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX 21 | # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2. 22 | export APACHE_LOG_DIR=/var/log/apache2$SUFFIX 23 | 24 | ## The locale used by some modules like mod_dav 25 | export LANG=C 26 | ## Uncomment the following line to use the system default locale instead: 27 | #. /etc/default/locale 28 | 29 | export LANG 30 | 31 | ## The command to get the status for 'apache2ctl status'. 32 | ## Some packages providing 'www-browser' need '--dump' instead of '-dump'. 33 | #export APACHE_LYNX='www-browser -dump' 34 | 35 | ## If you need a higher file descriptor limit, uncomment and adjust the 36 | ## following line (default is 8192): 37 | #APACHE_ULIMIT_MAX_FILES='ulimit -n 65536' 38 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/files/ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default 4 | # This is also true if you have upgraded from before 2.2.9-3 (i.e. from 5 | # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and 6 | # README.Debian.gz 7 | 8 | NameVirtualHost *:80 9 | Listen 80 10 | 11 | 12 | # If you add NameVirtualHost *:443 here, you will also have to change 13 | # the VirtualHost statement in /etc/apache2/sites-available/default-ssl 14 | # to 15 | # Server Name Indication for SSL named virtual hosts is currently not 16 | # supported by MSIE on Windows XP. 17 | Listen 443 18 | 19 | 20 | 21 | Listen 443 22 | 23 | 24 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/manifests/conf.pp: -------------------------------------------------------------------------------- 1 | # == Define: conf 2 | # 3 | # Adds an Apache configuration file. 4 | # 5 | define apache::conf() { 6 | file { "/etc/apache2/${name}": 7 | source => "puppet:///modules/apache/${name}", 8 | require => Package['apache2'], 9 | notify => Service['apache2']; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache 2 | # 3 | # Installs packages for Apache2, enables modules, and sets config files. 4 | # 5 | class apache { 6 | package { ['apache2', 'apache2-mpm-prefork']: 7 | ensure => present; 8 | } 9 | 10 | service { 'apache2': 11 | ensure => running, 12 | require => Package['apache2']; 13 | } 14 | 15 | apache::conf { ['apache2.conf', 'envvars', 'ports.conf']: } 16 | apache::module { ['expires.load', 'proxy.conf', 'proxy.load', 'proxy_http.load', 'rewrite.load']: } 17 | } 18 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache/manifests/module.pp: -------------------------------------------------------------------------------- 1 | # == Define: module 2 | # 3 | # Enables an Apache module. 4 | # 5 | define apache::module() { 6 | file { "/etc/apache2/mods-enabled/${name}": 7 | ensure => link, 8 | target => "/etc/apache2/mods-available/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache_vhosts/files/dynamic-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName dynamic-site 4 | 5 | DocumentRoot /var/www/dynamic-site/public 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/dynamic-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/dynamic-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache_vhosts/files/static-site: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | ServerName static-site 4 | 5 | DocumentRoot /var/www/static-site 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | 10 | 11 | Options Indexes FollowSymLinks MultiViews 12 | AllowOverride None 13 | Order allow,deny 14 | allow from all 15 | 16 | 17 | ErrorLog ${APACHE_LOG_DIR}/static-site-error.log 18 | 19 | # Possible values include: debug, info, notice, warn, error, crit, 20 | # alert, emerg. 21 | LogLevel warn 22 | 23 | CustomLog ${APACHE_LOG_DIR}/static-site-access.log combined 24 | 25 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache_vhosts/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: apache_vhosts 2 | # 3 | # Adds and enables virtual hosts. Sets up /var/www symlinks. 4 | # 5 | class apache_vhosts { 6 | file { '/var/www': 7 | ensure => directory; 8 | } 9 | 10 | apache_vhosts::vhost { ['static-site', 'dynamic-site']: } 11 | } 12 | -------------------------------------------------------------------------------- /example7/puppet/modules/apache_vhosts/manifests/vhost.pp: -------------------------------------------------------------------------------- 1 | # == Define: vhost 2 | # 3 | # Adds and enables an Apache virtual host 4 | # 5 | define apache_vhosts::vhost() { 6 | file { 7 | "/etc/apache2/sites-available/${name}": 8 | source => "puppet:///modules/apache_vhosts/${name}", 9 | require => Package['apache2'], 10 | notify => Service['apache2']; 11 | 12 | "/etc/apache2/sites-enabled/${name}": 13 | ensure => link, 14 | target => "/etc/apache2/sites-available/${name}", 15 | notify => Service['apache2']; 16 | 17 | "/var/www/${name}": 18 | ensure => link, 19 | target => "/vagrant/sites/${name}"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example7/puppet/modules/baseconfig/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=50000 17 | HISTFILESIZE=50000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | alias ll='ls -alF' 86 | alias la='ls -A' 87 | alias l='ls -CF' 88 | 89 | # Add an "alert" alias for long running commands. Use like so: 90 | # sleep 10; alert 91 | alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 92 | 93 | # Alias definitions. 94 | # You may want to put all your additions into a separate file like 95 | # ~/.bash_aliases, instead of adding them here directly. 96 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 97 | 98 | if [ -f ~/.bash_aliases ]; then 99 | . ~/.bash_aliases 100 | fi 101 | 102 | # enable programmable completion features (you don't need to enable 103 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 104 | # sources /etc/bash.bashrc). 105 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 106 | . /etc/bash_completion 107 | fi 108 | -------------------------------------------------------------------------------- /example7/puppet/modules/baseconfig/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: baseconfig 2 | # 3 | # Performs initial configuration tasks for all Vagrant boxes. 4 | # 5 | class baseconfig { 6 | exec { 'apt-get update': 7 | command => '/usr/bin/apt-get update'; 8 | } 9 | 10 | host { 'hostmachine': 11 | ip => '192.168.0.1'; 12 | } 13 | 14 | file { 15 | '/home/ubuntu/.bashrc': 16 | owner => 'ubuntu', 17 | group => 'ubuntu', 18 | mode => '0644', 19 | source => 'puppet:///modules/baseconfig/bashrc'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example7/puppet/modules/mysql/files/my.cnf: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MANAGED BY PUPPET. 2 | # ANY MANUAL CHANGES WILL BE AUTOMATICALLY REVERTED. 3 | 4 | # 5 | # The MySQL database server configuration file. 6 | # 7 | # You can copy this to one of: 8 | # - "/etc/mysql/my.cnf" to set global options, 9 | # - "~/.my.cnf" to set user-specific options. 10 | # 11 | # One can use all long options that the program supports. 12 | # Run program with --help to get a list of available options and with 13 | # --print-defaults to see which it would actually understand and use. 14 | # 15 | # For explanations see 16 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 17 | 18 | # This will be passed to all mysql clients 19 | # It has been reported that passwords should be enclosed with ticks/quotes 20 | # escpecially if they contain "#" chars... 21 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 22 | [client] 23 | port = 3306 24 | socket = /var/run/mysqld/mysqld.sock 25 | 26 | # Here is entries for some specific programs 27 | # The following values assume you have at least 32M ram 28 | 29 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 30 | [mysqld_safe] 31 | socket = /var/run/mysqld/mysqld.sock 32 | nice = 0 33 | 34 | [mysqld] 35 | # 36 | # * Basic Settings 37 | # 38 | user = mysql 39 | pid-file = /var/run/mysqld/mysqld.pid 40 | socket = /var/run/mysqld/mysqld.sock 41 | port = 3306 42 | basedir = /usr 43 | datadir = /var/lib/mysql 44 | tmpdir = /tmp 45 | language = /usr/share/mysql/english 46 | skip-external-locking 47 | # 48 | # Instead of skip-networking the default is now to listen only on 49 | # localhost which is more compatible and is not less secure. 50 | #bind-address = 127.0.0.1 51 | # 52 | # * Fine Tuning 53 | # 54 | key_buffer = 16M 55 | max_allowed_packet = 16M 56 | thread_stack = 256K 57 | thread_cache_size = 8 58 | # This replaces the startup script and checks MyISAM tables if needed 59 | # the first time they are touched 60 | #myisam-recover = BACKUP 61 | #max_connections = 100 62 | #table_cache = 64 63 | #thread_concurrency = 10 64 | # 65 | # * Query Cache Configuration 66 | # 67 | query_cache_limit = 1M 68 | query_cache_size = 16M 69 | # 70 | # * Logging and Replication 71 | # 72 | # Both location gets rotated by the cronjob. 73 | # Be aware that this log type is a performance killer. 74 | #log = /var/log/mysql/mysql.log 75 | # 76 | # Error logging goes to syslog. This is a Debian improvement :) 77 | # 78 | # Here you can see queries with especially long duration 79 | #log_slow_queries = /var/log/mysql/mysql-slow.log 80 | #long_query_time = 2 81 | #log-queries-not-using-indexes 82 | # 83 | # The following can be used as easy to replay backup logs or for replication. 84 | # note: if you are setting up a replication slave, see README.Debian about 85 | # other settings you may need to change. 86 | #server-id = 1 87 | #log_bin = /var/log/mysql/mysql-bin.log 88 | expire_logs_days = 10 89 | max_binlog_size = 100M 90 | #binlog_do_db = include_database_name 91 | #binlog_ignore_db = include_database_name 92 | # 93 | # * BerkeleyDB 94 | # 95 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 96 | #skip-bdb 97 | # 98 | # * InnoDB 99 | # 100 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 101 | # Read the manual for more InnoDB related options. There are many! 102 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 103 | #skip-innodb 104 | # 105 | # * Federated 106 | # 107 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 108 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 109 | # 110 | #skip-federated 111 | # 112 | # * Security Features 113 | # 114 | # Read the manual, too, if you want chroot! 115 | # chroot = /var/lib/mysql/ 116 | # 117 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 118 | # 119 | # ssl-ca=/etc/mysql/cacert.pem 120 | # ssl-cert=/etc/mysql/server-cert.pem 121 | # ssl-key=/etc/mysql/server-key.pem 122 | 123 | 124 | 125 | [mysqldump] 126 | quick 127 | quote-names 128 | max_allowed_packet = 16M 129 | 130 | [mysql] 131 | #no-auto-rehash # faster start of mysql but no tab completition 132 | 133 | [isamchk] 134 | key_buffer = 16M 135 | 136 | # 137 | # * NDB Cluster 138 | # 139 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 140 | # 141 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 142 | # not from the NDB Management Nodes (ndb_mgmd processes). 143 | # 144 | # [MYSQL_CLUSTER] 145 | # ndb-connectstring=127.0.0.1 146 | 147 | 148 | # 149 | # * IMPORTANT: Additional settings that can override those from this file! 150 | # The files must end with '.cnf', otherwise they'll be ignored. 151 | # 152 | !includedir /etc/mysql/conf.d/ 153 | 154 | -------------------------------------------------------------------------------- /example7/puppet/modules/mysql/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: mysql 2 | # 3 | # Installs MySQL server, sets config file, and loads database for dynamic site. 4 | # 5 | class mysql { 6 | package { ['mysql-server']: 7 | ensure => present; 8 | } 9 | 10 | service { 'mysql': 11 | ensure => running, 12 | require => Package['mysql-server']; 13 | } 14 | 15 | file { '/etc/mysql/my.cnf': 16 | source => 'puppet:///modules/mysql/my.cnf', 17 | require => Package['mysql-server'], 18 | notify => Service['mysql']; 19 | } 20 | 21 | exec { 'set-mysql-password': 22 | unless => 'mysqladmin -uroot -proot status', 23 | command => "mysqladmin -uroot password root", 24 | path => ['/bin', '/usr/bin'], 25 | require => Service['mysql']; 26 | } 27 | 28 | exec { 'load-dynamic-sql': 29 | command => 'mysql -u root -proot < /vagrant/sites/dynamic.sql', 30 | path => ['/bin', '/usr/bin'], 31 | require => Exec['set-mysql-password']; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example7/puppet/modules/php/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: php 2 | # 3 | # Installs PHP5 and necessary modules. Sets config files. 4 | # 5 | class php { 6 | package { ['php5', 7 | 'php5-cli', 8 | 'libapache2-mod-php5', 9 | 'php-apc', 10 | 'php5-curl', 11 | 'php5-dev', 12 | 'php5-gd', 13 | 'php5-imagick', 14 | 'php5-mcrypt', 15 | 'php5-memcache', 16 | 'php5-mysql', 17 | 'php5-pspell', 18 | 'php5-sqlite', 19 | 'php5-tidy', 20 | 'php5-xdebug', 21 | 'php5-xmlrpc', 22 | 'php5-xsl']: 23 | ensure => present; 24 | } 25 | 26 | file { 27 | '/etc/php5/apache2': 28 | ensure => directory, 29 | before => File ['/etc/php5/apache2/php.ini']; 30 | 31 | '/etc/php5/apache2/php.ini': 32 | source => 'puppet:///modules/php/apache2-php.ini', 33 | require => Package['php5']; 34 | 35 | '/etc/php5/cli': 36 | ensure => directory, 37 | before => File ['/etc/php5/cli/php.ini']; 38 | 39 | '/etc/php5/cli/php.ini': 40 | source => 'puppet:///modules/php/cli-php.ini', 41 | require => Package['php5-cli']; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/config.php: -------------------------------------------------------------------------------- 1 | pdo = new PDO(DB_DSN, DB_USER, DB_PASS); 10 | } 11 | 12 | public function getItem($id) { 13 | $stmt = $this->pdo->prepare("SELECT * FROM WishListItem WHERE id = :id"); 14 | $stmt->execute(array(':id' => $id)); 15 | $result = $stmt->fetchAll(PDO::FETCH_CLASS, 'WishListItem'); 16 | return $result[0]; 17 | } 18 | 19 | public function getAllItems() { 20 | $query = "SELECT id, name, description FROM WishListItem ORDER BY id"; 21 | $result = $this->pdo->query($query); 22 | $result->setFetchMode(PDO::FETCH_CLASS, 'WishListItem'); 23 | return $result->fetchAll(); 24 | } 25 | 26 | public function addItem($name, $description) { 27 | $query = "INSERT INTO WishListItem (name, description) VALUES (:name, :desc)"; 28 | $params = array(':name' => $name, ':desc' => $description); 29 | $stmt = $this->pdo->prepare($query); 30 | $stmt->execute($params); 31 | } 32 | 33 | public function editItem($id, $name, $description) { 34 | $query = "UPDATE WishListItem SET name = :name, description = :desc WHERE id = :id"; 35 | $params = array(':id' => $id, ':name' => $name, ':desc' => $description); 36 | $stmt = $this->pdo->prepare($query); 37 | $stmt->execute($params); 38 | } 39 | 40 | public function deleteItem($id) { 41 | $stmt = $this->pdo->prepare("DELETE FROM WishListItem WHERE id = :id"); 42 | $stmt->execute(array(':id' => $id)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/models/WishListItem.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function getDescription() { 14 | return $this->description; 15 | } 16 | 17 | public function setId($id) { 18 | $this->id = $id; 19 | } 20 | 21 | public function getId() { 22 | return $this->id; 23 | } 24 | 25 | public function setName($name) { 26 | $this->name = $name; 27 | } 28 | 29 | public function getName() { 30 | return $this->name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/views/additem.php: -------------------------------------------------------------------------------- 1 |

Add New Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 |

14 |
15 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/views/allitems.php: -------------------------------------------------------------------------------- 1 |

Vagrant Wish List on EC2 (Example 7)

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
NameDescription
editgetName() ?>getDescription() ?>
16 |

add new item

17 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/views/edititem.php: -------------------------------------------------------------------------------- 1 |

Edit Item

2 |
3 |

4 | 5 | 6 |

7 |

8 | 9 | 10 |

11 |

12 | 13 | 14 | 15 |

16 |
17 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/views/footer.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/application/views/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Vagrant Wish List 5 | 6 | 7 | 8 | 9 |
10 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/public/add.php: -------------------------------------------------------------------------------- 1 | addItem($_POST['name'], $_POST['desc']); 9 | 10 | header('location: /'); 11 | exit; 12 | } 13 | 14 | require_once APPLICATION_DIR . '/views/header.php'; 15 | require_once APPLICATION_DIR . '/views/additem.php'; 16 | require_once APPLICATION_DIR . '/views/footer.php'; 17 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/public/assets/dynamic.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 15px; 8 | } 9 | 10 | p { 11 | margin-top: 12px; 12 | } 13 | 14 | input#name, input#desc { 15 | width: 300px; 16 | } 17 | 18 | input#add, input#edit, input#delete { 19 | color: #FFF; 20 | font: bold 18px Arial, sans-serif; 21 | background: #070; 22 | padding: 7px 14px; 23 | } 24 | 25 | input#delete { 26 | background: #700; 27 | } 28 | 29 | table th, table td { 30 | padding: 8px; 31 | border: 1px solid #777; 32 | } 33 | 34 | table th { 35 | background-color: #DDD; 36 | } 37 | 38 | #container { 39 | margin: 25px; 40 | padding: 15px; 41 | background-color: #FFF; 42 | border: 1px solid #444; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/public/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/public/edit.php: -------------------------------------------------------------------------------- 1 | editItem($_POST['id'], $_POST['name'], $_POST['desc']); 9 | header('location: /'); 10 | exit; 11 | } 12 | 13 | if (isset($_POST['delete'])) { 14 | $wishListDAO->deleteItem($_POST['id']); 15 | header('location: /'); 16 | exit; 17 | } 18 | 19 | $item = $wishListDAO->getItem($_GET['id']); 20 | 21 | require_once APPLICATION_DIR . '/views/header.php'; 22 | require_once APPLICATION_DIR . '/views/edititem.php'; 23 | require_once APPLICATION_DIR . '/views/footer.php'; 24 | -------------------------------------------------------------------------------- /example7/sites/dynamic-site/public/index.php: -------------------------------------------------------------------------------- 1 | getAllItems(); 7 | 8 | require_once APPLICATION_DIR . '/views/header.php'; 9 | require_once APPLICATION_DIR . '/views/allitems.php'; 10 | require_once APPLICATION_DIR . '/views/footer.php'; 11 | -------------------------------------------------------------------------------- /example7/sites/dynamic.sql: -------------------------------------------------------------------------------- 1 | -- create database for the dynamic site 2 | CREATE DATABASE IF NOT EXISTS dynamic; 3 | 4 | -- create a new user for the Web app 5 | DELETE FROM mysql.user WHERE User = 'webuser'; 6 | CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'vagrantrocks'; 7 | 8 | -- grant only the necessary privileges to our new user 9 | GRANT SELECT, INSERT, UPDATE, DELETE ON dynamic.* TO 'webuser'@'localhost'; 10 | 11 | -- make this our active database 12 | USE dynamic; 13 | 14 | -- create a table to store our wish list items 15 | DROP TABLE IF EXISTS `WishListItem`; 16 | CREATE TABLE IF NOT EXISTS `WishListItem` ( 17 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 18 | `name` varchar(64) NOT NULL, 19 | `description` varchar(255), 20 | 21 | PRIMARY KEY (`id`) 22 | ) ENGINE=InnoDB; 23 | 24 | -- start with some data in the table 25 | INSERT INTO WishListItem (name, description) VALUES ('Pro Puppet book', 'I wanna be a Puppet pro.'); 26 | INSERT INTO WishListItem (name, description) VALUES ('Red Rider BB Gun', 'I will NOT shoot my eye out.'); 27 | INSERT INTO WishListItem (name, description) VALUES ('Soccer cleats', 'For ultimate frisbee. Good luck finding a size 14.'); 28 | -------------------------------------------------------------------------------- /example7/sites/static-site/assets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 3 | * Richard Clark (http://richclarkdesign.com) 4 | * http://cssreset.com 5 | */ 6 | html, body, div, span, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | abbr, address, cite, code, 9 | del, dfn, em, img, ins, kbd, q, samp, 10 | small, strong, sub, sup, var, 11 | b, i, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, figcaption, figure, 16 | footer, header, hgroup, menu, nav, section, summary, 17 | time, mark, audio, video { 18 | margin:0; 19 | padding:0; 20 | border:0; 21 | outline:0; 22 | font-size:100%; 23 | vertical-align:baseline; 24 | background:transparent; 25 | } 26 | body { 27 | line-height:1; 28 | } 29 | article,aside,details,figcaption,figure, 30 | footer,header,hgroup,menu,nav,section { 31 | display:block; 32 | } 33 | nav ul { 34 | list-style:none; 35 | } 36 | blockquote, q { 37 | quotes:none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content:''; 42 | content:none; 43 | } 44 | a { 45 | margin:0; 46 | padding:0; 47 | font-size:100%; 48 | vertical-align:baseline; 49 | background:transparent; 50 | } 51 | /* change colours to suit your needs */ 52 | ins { 53 | background-color:#ff9; 54 | color:#000; 55 | text-decoration:none; 56 | } 57 | /* change colours to suit your needs */ 58 | mark { 59 | background-color:#ff9; 60 | color:#000; 61 | font-style:italic; 62 | font-weight:bold; 63 | } 64 | del { 65 | text-decoration: line-through; 66 | } 67 | abbr[title], dfn[title] { 68 | border-bottom:1px dotted; 69 | cursor:help; 70 | } 71 | table { 72 | border-collapse:collapse; 73 | border-spacing:0; 74 | } 75 | /* change border colour to suit your needs */ 76 | hr { 77 | display:block; 78 | height:1px; 79 | border:0; 80 | border-top:1px solid #cccccc; 81 | margin:1em 0; 82 | padding:0; 83 | } 84 | input, select { 85 | vertical-align:middle; 86 | } 87 | -------------------------------------------------------------------------------- /example7/sites/static-site/assets/static.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #AAA; 3 | } 4 | 5 | h1 { 6 | font-size: 24px; 7 | margin-bottom: 10px; 8 | } 9 | 10 | #container { 11 | margin: 25px; 12 | padding: 15px; 13 | background: #FFF; 14 | border: 1px solid #444; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /example7/sites/static-site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Static Site 5 | 6 | 7 | 8 | 9 |
10 |

Static Site (Example 7)

11 |

This is an example of a static Web site configured via Puppet and Vagrant.

12 |

And it's being served up from an EC2 instance we just created.

13 |
14 | 15 | 16 | --------------------------------------------------------------------------------