Merge pull request #1329 from GPCsolutions/vagrant

Vagrant
This commit is contained in:
Laurent Destailleur 2013-11-29 06:38:48 -08:00
commit 3f89f27a0c
17 changed files with 1472 additions and 1 deletions

6
.gitignore vendored
View File

@ -16,4 +16,8 @@ doxygen_warnings.log
.idea
*.iml
Thumbs.db
# Vagrant generated files
.vagrant
/index.html
/phpmyadmin
/xhprof

0
dev/initdata/dolibarr-mysql2pgsql.pl Normal file → Executable file
View File

0
dev/initdata/mysqldump_dolibarr_3.0.0.sql Executable file → Normal file
View File

0
dev/initdata/mysqldump_dolibarr_3.1.0.sql Executable file → Normal file
View File

60
dev/vagrant/README.md Normal file
View File

@ -0,0 +1,60 @@
Vagrant development box for Dolibarr
====================================
Introduction
------------
[Vagrant](http://vagrantup.com) is a tool to make development easier using [VirtualBox](http://virtualbox.org) virtual machines.
These machines have been created with [PuPHEt](http://puphpet.com) and combine the power of Vagrant with [Puppet](http://puppetlabs.com) to automate the development machine provisionning.
What you need
-------------
Latest versions of:
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
- [Vagrant](http://downloads.vagrantup.com/)
Usage
-----
### VM startup
`cd` into the vagrant box directory and simply type `vagrant up`.
That's all you need to do. It will build a brand new VirtalBox machine for you with everything you need to develop on Dolibarr.
### Name resolution
For easy access to the VM you need to setup name resolution to the machines IP.
Edit the [hosts](https://fr.wikipedia.org/wiki/Hosts) file on the machine you run Vagrant on to map the virtual machine's IP to it's Vhost name.
Example syntax:
192.168.42.101 dev.dolibarr.org
Once this is done, you will be able to access your VM's service at <http://dolibarr.dev>
Available boxes
---------------
### dolibardev
Somewhat bleeding edge vagrant box for develop branch related work.
- IP: 192.168.42.101
- Vhost: dev.dolibarr.org
- OS: Debian Wheezy 7.2
- Webserver: Apache 2.2
- PHP: mod_php 5.5
- Database: MySQL 5.5
- Root user: root
- Root password: root
- Database name: dolibarr
- Database user: user
- Database password: user
- Initial data: dev/initdata/mysqldump_dolibarr-3.5.0.sql
- Debugger: XDebug
- Profiler: Xhprof
- phpMyAdmin: <http://192.168.42.101/phpmyadmin>

42
dev/vagrant/dolibarrdev/Vagrantfile vendored Normal file
View File

@ -0,0 +1,42 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian-wheezy72-x64-vbox43"
config.vm.box_url = "https://puphpet.s3.amazonaws.com/debian-wheezy72-x64-vbox43.box"
config.vm.network "private_network", ip: "192.168.42.101"
config.vm.synced_folder "../../../", "/var/www", id: "vagrant-root", :nfs => false, owner: "www-data", group: "www-data"
config.vm.usable_port_range = (2200..2250)
config.vm.provider :virtualbox do |virtualbox|
virtualbox.customize ["modifyvm", :id, "--name", "dolibarrdev"]
virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
virtualbox.customize ["modifyvm", :id, "--memory", "512"]
virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
config.vm.provision :shell, :path => "shell/initial-setup.sh"
config.vm.provision :shell, :path => "shell/update-puppet.sh"
config.vm.provision :shell, :path => "shell/librarian-puppet-vagrant.sh"
config.vm.provision :puppet do |puppet|
puppet.facter = {
"ssh_username" => "vagrant"
}
puppet.manifests_path = "puppet/manifests"
puppet.options = ["--verbose", "--hiera_config /vagrant/hiera.yaml", "--parser future"]
end
config.ssh.username = "vagrant"
config.ssh.shell = "bash -l"
config.ssh.keep_alive = true
config.ssh.forward_agent = false
config.ssh.forward_x11 = false
config.vagrant.host = :detect
end

View File

@ -0,0 +1,52 @@
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
__has_parent_dir () {
# Utility function so we can test for things like .git/.hg without firing up a
# separate process
test -d "$1" && return 0;
current="."
while [ ! "$current" -ef "$current/.." ]; do
if [ -d "$current/$1" ]; then
return 0;
fi
current="$current/..";
done
return 1;
}
__vcs_name() {
if [ -d .svn ]; then
echo "-[svn]";
elif __has_parent_dir ".git"; then
echo "-[$(__git_ps1 'git %s')]";
elif __has_parent_dir ".hg"; then
echo "-[hg $(hg branch)]"
fi
}
black=$(tput -Txterm setaf 0)
red=$(tput -Txterm setaf 1)
green=$(tput -Txterm setaf 2)
yellow=$(tput -Txterm setaf 3)
dk_blue=$(tput -Txterm setaf 4)
pink=$(tput -Txterm setaf 5)
lt_blue=$(tput -Txterm setaf 6)
bold=$(tput -Txterm bold)
reset=$(tput -Txterm sgr0)
# Nicely formatted terminal prompt
export PS1='\n\[$bold\]\[$black\][\[$dk_blue\]\@\[$black\]]-[\[$green\]\u\[$yellow\]@\[$green\]\h\[$black\]]-[\[$pink\]\w\[$black\]]\[\033[0;33m\]$(__vcs_name) \[\033[00m\]\[$reset\]\n\[$reset\]\$ '
alias ls='ls -F --color=always'
alias dir='dir -F --color=always'
alias ll='ls -l'
alias cp='cp -iv'
alias rm='rm -i'
alias mv='mv -iv'
alias grep='grep --color=auto -in'
alias ..='cd ..'

View File

@ -0,0 +1,414 @@
set rtp+=$GOROOT/misc/vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
"
" Awesome_version:
" Get this config, nice color schemes and lots of plugins!
"
" Install the awesome version from:
"
" https://github.com/amix/vimrc
"
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
"
" Raw_version:
" http://amix.dk/vim/vimrc.txt
"
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Moving around, tabs and buffers
" -> Status line
" -> Editing mappings
" -> vimgrep searching and cope displaying
" -> Spell checking
" -> Misc
" -> Helper functions
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugins
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" :W sudo saves the file
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
endif
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Add a bit extra margin to the left
set foldcolumn=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
try
colorscheme desert
catch
endtry
set background=dark
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f', '')<CR>
vnoremap <silent> # :call VisualSelection('b', '')<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
map <space> /
map <c-space> ?
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,1000 bd!<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vimgrep searching and cope displaying
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
" Open vimgrep and put the cursor in the right position
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
" Vimgreps in the current file
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
" Do :help cope if you are unsure what cope is. It's super useful!
"
" When you search with vimgrep, display your results in cope by doing:
" <leader>cc
"
" To go to the next search result do:
" <leader>n
"
" To go to the previous search results do:
" <leader>p
"
map <leader>cc :botright cope<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Quickly open a buffer for scripbble
map <leader>q :e ~/buffer<cr>
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.' . a:extra_filter)
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction

View File

@ -0,0 +1,7 @@
---
:backends: yaml
:yaml:
:datadir: '/vagrant/puppet/hieradata'
:hierarchy:
- common
:logger: console

View File

@ -0,0 +1,13 @@
forge "http://forge.puppetlabs.com"
mod 'stdlib', :git => 'git://github.com/puphpet/puppetlabs-stdlib.git'
mod 'concat', :git => 'git://github.com/puphpet/puppetlabs-concat.git'
mod 'apt', :git => 'git://github.com/puphpet/puppetlabs-apt.git'
mod 'yum', :git => 'git://github.com/puphpet/puppet-yum.git'
mod 'vcsrepo', :git => 'git://github.com/puphpet/puppetlabs-vcsrepo.git'
mod 'ntp', :git => 'git://github.com/puphpet/puppetlabs-ntp.git'
mod 'iptables', :git => 'git://github.com/puphpet/puppet-iptables.git'
mod 'apache', :git => 'git://github.com/puphpet/puppetlabs-apache.git'
mod 'php', :git => 'git://github.com/puphpet/puppet-php.git'
mod 'composer', :git => 'git://github.com/puphpet/puppet-composer.git'
mod 'puphpet', :git => 'git://github.com/puphpet/puppet-puphpet.git'
mod 'mysql', :git => 'git://github.com/puphpet/puppetlabs-mysql.git'

View File

@ -0,0 +1,121 @@
---
vagrantfile-local:
vm:
box: debian-wheezy72-x64-vbox43
box_url: 'https://puphpet.s3.amazonaws.com/debian-wheezy72-x64-vbox43.box'
hostname: null
network:
private_network: 192.168.42.101
forwarded_port:
IoUPe5V4KFVe:
host: ''
guest: ''
provider:
virtualbox:
modifyvm:
name: dolibarrdev
natdnshostresolver1: on
memory: '512'
setextradata:
VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root: 1
provision:
puppet:
manifests_path: puppet/manifests
options:
- --verbose
- '--hiera_config /vagrant/hiera.yaml'
- '--parser future'
synced_folder:
w8TR2T1V5h4o:
id: vagrant-root
source: ../../../
target: /var/www
nfs: 'false'
usable_port_range: 2200..2250
ssh:
host: null
port: null
private_key_path: null
username: vagrant
guest_port: null
keep_alive: true
forward_agent: false
forward_x11: false
shell: 'bash -l'
vagrant:
host: ':detect'
server:
packages:
- nano
- ack-grep
dot_files:
-
bash_aliases: null
_prevent_empty: ''
apache:
modules:
- php
- rewrite
vhosts:
vkJFW364QjeN:
servername: dev.dolibarr.org
docroot: /var/www/htdocs
port: '80'
setenv:
- 'APP_ENV dev'
override:
- All
user: www-data
group: www-data
default_vhost: true
mpm_module: prefork
php:
version: '55'
composer: '1'
modules:
php:
- cli
- intl
- mcrypt
- curl
- imagick
- gd
pear: { }
pecl: { }
ini:
display_errors: On
error_reporting: '-1'
session.save_path: /var/lib/php/session
timezone: UTC
xdebug:
install: '1'
settings:
xdebug.default_enable: '1'
xdebug.remote_autostart: '0'
xdebug.remote_connect_back: '1'
xdebug.remote_enable: '1'
xdebug.remote_handler: dbgp
xdebug.remote_port: '9000'
xhprof:
install: '1'
location: /var/www/xhprof
mysql:
root_password: root
phpmyadmin: '1'
databases:
4TUR1gNNdrQV:
grant:
- ALTER
- CREATE
- DELETE
- DROP
- INDEX
- INSERT
- SELECT
- UPDATE
name: dolibarr
host: localhost
user: user
password: user
sql_file: /var/www/dev/initdata/mysqldump_dolibarr_3.5.0.sql

View File

@ -0,0 +1,541 @@
## Begin Server manifest
if $server_values == undef {
$server_values = hiera('server', false)
}
# Ensure the time is accurate, reducing the possibilities of apt repositories
# failing for invalid certificates
include '::ntp'
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }
group { 'puppet': ensure => present }
group { 'www-data': ensure => present }
user { $::ssh_username:
shell => '/bin/bash',
home => "/home/${::ssh_username}",
ensure => present
}
user { ['apache', 'nginx', 'httpd', 'www-data']:
shell => '/bin/bash',
ensure => present,
groups => 'www-data',
require => Group['www-data']
}
file { "/home/${::ssh_username}":
ensure => directory,
owner => $::ssh_username,
}
# copy dot files to ssh user's home directory
exec { 'dotfiles':
cwd => "/home/${::ssh_username}",
command => "cp -r /vagrant/files/dot/.[a-zA-Z0-9]* /home/${::ssh_username}/ && chown -R ${::ssh_username} /home/${::ssh_username}/.[a-zA-Z0-9]*",
onlyif => "test -d /vagrant/files/dot",
require => User[$::ssh_username]
}
case $::osfamily {
# debian, ubuntu
'debian': {
class { 'apt': }
Class['::apt::update'] -> Package <|
title != 'python-software-properties'
and title != 'software-properties-common'
|>
ensure_packages( ['augeas-tools'] )
}
# redhat, centos
'redhat': {
class { 'yum': extrarepo => ['epel'] }
Class['::yum'] -> Yum::Managed_yumrepo <| |> -> Package <| |>
exec { 'bash_git':
cwd => "/home/${::ssh_username}",
command => "curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > /home/${::ssh_username}/.bash_git",
creates => "/home/${::ssh_username}/.bash_git"
}
file_line { 'link ~/.bash_git':
ensure => present,
line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi',
path => "/home/${::ssh_username}/.bash_profile",
require => [
Exec['dotfiles'],
Exec['bash_git'],
]
}
file_line { 'link ~/.bash_aliases':
ensure => present,
line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi',
path => "/home/${::ssh_username}/.bash_profile",
require => [
File_line['link ~/.bash_git'],
]
}
ensure_packages( ['augeas'] )
}
}
if $php_values == undef {
$php_values = hiera('php', false)
}
case $::operatingsystem {
'debian': {
add_dotdeb { 'packages.dotdeb.org': release => $lsbdistcodename }
if is_hash($php_values) {
# Debian Squeeze 6.0 can do PHP 5.3 (default) and 5.4
if $lsbdistcodename == 'squeeze' and $php_values['version'] == '54' {
add_dotdeb { 'packages.dotdeb.org-php54': release => 'squeeze-php54' }
}
# Debian Wheezy 7.0 can do PHP 5.4 (default) and 5.5
elsif $lsbdistcodename == 'wheezy' and $php_values['version'] == '55' {
add_dotdeb { 'packages.dotdeb.org-php55': release => 'wheezy-php55' }
}
}
}
'ubuntu': {
apt::key { '4F4EA0AAE5267A6C': }
if is_hash($php_values) {
# Ubuntu Lucid 10.04, Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.3 (default <= 12.10) and 5.4 (default <= 13.04)
if $lsbdistcodename in ['lucid', 'precise', 'quantal', 'raring'] and $php_values['version'] == '54' {
if $lsbdistcodename == 'lucid' {
apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'], options => '' }
} else {
apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'] }
}
}
# Ubuntu Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.5
elsif $lsbdistcodename in ['precise', 'quantal', 'raring'] and $php_values['version'] == '55' {
apt::ppa { 'ppa:ondrej/php5': require => Apt::Key['4F4EA0AAE5267A6C'] }
}
elsif $lsbdistcodename in ['lucid'] and $php_values['version'] == '55' {
err('You have chosen to install PHP 5.5 on Ubuntu 10.04 Lucid. This will probably not work!')
}
}
}
'redhat', 'centos': {
if is_hash($php_values) {
if $php_values['version'] == '54' {
class { 'yum::repo::remi': }
}
# remi_php55 requires the remi repo as well
elsif $php_values['version'] == '55' {
class { 'yum::repo::remi': }
class { 'yum::repo::remi_php55': }
}
}
}
}
if !empty($server_values['packages']) {
ensure_packages( $server_values['packages'] )
}
define add_dotdeb ($release){
apt::source { $name:
location => 'http://packages.dotdeb.org',
release => $release,
repos => 'all',
required_packages => 'debian-keyring debian-archive-keyring',
key => '89DF5277',
key_server => 'keys.gnupg.net',
include_src => true
}
}
## Begin Apache manifest
if $yaml_values == undef {
$yaml_values = loadyaml('/vagrant/puppet/hieradata/common.yaml')
}
if $apache_values == undef {
$apache_values = $yaml_values['apache']
}
include puphpet::params
$webroot_location = $puphpet::params::apache_webroot_location
exec { "exec mkdir -p ${webroot_location}":
command => "mkdir -p ${webroot_location}",
onlyif => "test -d ${webroot_location}",
}
if ! defined(File[$webroot_location]) {
file { $webroot_location:
ensure => directory,
group => 'www-data',
mode => 0775,
require => [
Exec["exec mkdir -p ${webroot_location}"],
Group['www-data']
]
}
}
class { 'apache':
user => $apache_values['user'],
group => $apache_values['group'],
default_vhost => $apache_values['default_vhost'],
mpm_module => $apache_values['mpm_module'],
manage_user => false,
manage_group => false
}
if $::osfamily == 'debian' {
case $apache_values['mpm_module'] {
'prefork': { ensure_packages( ['apache2-mpm-prefork'] ) }
'worker': { ensure_packages( ['apache2-mpm-worker'] ) }
'event': { ensure_packages( ['apache2-mpm-event'] ) }
}
} elsif $::osfamily == 'redhat' and ! defined(Iptables::Allow['tcp/80']) {
iptables::allow { 'tcp/80':
port => '80',
protocol => 'tcp'
}
}
create_resources(apache::vhost, $apache_values['vhosts'])
define apache_mod {
if ! defined(Class["apache::mod::${name}"]) {
class { "apache::mod::${name}": }
}
}
if count($apache_values['modules']) > 0 {
apache_mod { $apache_values['modules']: }
}
## Begin PHP manifest
if $php_values == undef {
$php_values = hiera('php', false)
}
if $apache_values == undef {
$apache_values = hiera('apache', false)
}
if $nginx_values == undef {
$nginx_values = hiera('nginx', false)
}
Class['Php'] -> Class['Php::Devel'] -> Php::Module <| |> -> Php::Pear::Module <| |> -> Php::Pecl::Module <| |>
if $php_prefix == undef {
$php_prefix = $::operatingsystem ? {
/(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => 'php5-',
default => 'php-',
}
}
if $php_fpm_ini == undef {
$php_fpm_ini = $::operatingsystem ? {
/(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => '/etc/php5/fpm/php.ini',
default => '/etc/php.ini',
}
}
if is_hash($apache_values) {
include apache::params
$php_webserver_service = 'httpd'
$php_webserver_user = $apache::params::user
class { 'php':
service => $php_webserver_service
}
} elsif is_hash($nginx_values) {
include nginx::params
$php_webserver_service = "${php_prefix}fpm"
$php_webserver_user = $nginx::params::nx_daemon_user
class { 'php':
package => $php_webserver_service,
service => $php_webserver_service,
service_autorestart => false,
config_file => $php_fpm_ini,
}
service { $php_webserver_service:
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
require => Package[$php_webserver_service]
}
}
class { 'php::devel': }
if count($php_values['modules']['php']) > 0 {
php_mod { $php_values['modules']['php']:; }
}
if count($php_values['modules']['pear']) > 0 {
php_pear_mod { $php_values['modules']['pear']:; }
}
if count($php_values['modules']['pecl']) > 0 {
php_pecl_mod { $php_values['modules']['pecl']:; }
}
if count($php_values['ini']) > 0 {
$php_values['ini'].each { |$key, $value|
puphpet::ini { $key:
entry => "CUSTOM/${key}",
value => $value,
php_version => $php_values['version'],
webserver => $php_webserver_service
}
}
if $php_values['ini']['session.save_path'] != undef {
exec {"mkdir -p ${php_values['ini']['session.save_path']}":
onlyif => "test ! -d ${php_values['ini']['session.save_path']}",
}
file { $php_values['ini']['session.save_path']:
ensure => directory,
group => 'www-data',
mode => 0775,
require => Exec["mkdir -p ${php_values['ini']['session.save_path']}"]
}
}
}
puphpet::ini { $key:
entry => 'CUSTOM/date.timezone',
value => $php_values['timezone'],
php_version => $php_values['version'],
webserver => $php_webserver_service
}
define php_mod {
php::module { $name: }
}
define php_pear_mod {
php::pear::module { $name: use_package => false }
}
define php_pecl_mod {
php::pecl::module { $name: use_package => false }
}
if $php_values['composer'] == 1 {
class { 'composer':
target_dir => '/usr/local/bin',
composer_file => 'composer',
download_method => 'curl',
logoutput => false,
tmp_path => '/tmp',
php_package => "${php::params::module_prefix}cli",
curl_package => 'curl',
suhosin_enabled => false,
}
}
if $xdebug_values == undef {
$xdebug_values = hiera('xdebug', false)
}
if is_hash($apache_values) {
$xdebug_webserver_service = 'httpd'
} elsif is_hash($nginx_values) {
$xdebug_webserver_service = 'nginx'
} else {
$xdebug_webserver_service = undef
}
if $xdebug_values['install'] != undef and $xdebug_values['install'] == 1 {
class { 'puphpet::xdebug':
webserver => $xdebug_webserver_service
}
if is_hash($xdebug_values['settings']) and count($xdebug_values['settings']) > 0 {
$xdebug_values['settings'].each { |$key, $value|
puphpet::ini { $key:
entry => "XDEBUG/${key}",
value => $value,
php_version => $php_values['version'],
webserver => $xdebug_webserver_service
}
}
}
}
## Begin Xhprof manifest
if $xhprof_values == undef {
$xhprof_values = hiera('xhprof', false)
}
if is_hash($xhprof_values) and $xhprof_values['install'] == 1 {
$xhprofPath = $xhprof_values['location']
php::pecl::module { 'xhprof':
use_package => false,
preferred_state => 'beta',
}
exec { 'delete-xhprof-path-if-not-git-repo':
command => "rm -rf ${xhprofPath}",
onlyif => "test ! -d ${xhprofPath}/.git"
}
vcsrepo { $xhprofPath:
ensure => present,
provider => git,
source => 'https://github.com/facebook/xhprof.git',
require => Exec['delete-xhprof-path-if-not-git-repo']
}
file { "${xhprofPath}/xhprof_html":
ensure => directory,
mode => 0775,
require => Vcsrepo[$xhprofPath]
}
composer::exec { 'xhprof-composer-run':
cmd => 'install',
cwd => $xhprofPath,
require => [
Class['composer'],
File["${xhprofPath}/xhprof_html"]
]
}
}
## Begin MySQL manifest
if $mysql_values == undef {
$mysql_values = hiera('mysql', false)
}
if $php_values == undef {
$php_values = hiera('php', false)
}
if $apache_values == undef {
$apache_values = hiera('apache', false)
}
if $nginx_values == undef {
$nginx_values = hiera('nginx', false)
}
if $mysql_values['root_password'] {
class { 'mysql::server':
root_password => $mysql_values['root_password'],
}
if is_hash($mysql_values['databases']) and count($mysql_values['databases']) > 0 {
create_resources(mysql_db, $mysql_values['databases'])
}
if is_hash($php_values) {
if $::osfamily == 'redhat' and $php_values['version'] == '53' and ! defined(Php::Module['mysql']) {
php::module { 'mysql': }
} elsif ! defined(Php::Module['mysqlnd']) {
php::module { 'mysqlnd': }
}
}
}
define mysql_db (
$user,
$password,
$host,
$grant = [],
$sql_file = false
) {
if $name == '' or $password == '' or $host == '' {
fail( 'MySQL DB requires that name, password and host be set. Please check your settings!' )
}
mysql::db { $name:
user => $user,
password => $password,
host => $host,
grant => $grant,
sql => $sql_file,
}
}
if $mysql_values['phpmyadmin'] == 1 and is_hash($php_values) {
if $::osfamily == 'debian' {
if $::operatingsystem == 'ubuntu' {
apt::key { '80E7349A06ED541C': }
apt::ppa { 'ppa:nijel/phpmyadmin': require => Apt::Key['80E7349A06ED541C'] }
}
$phpMyAdmin_package = 'phpmyadmin'
$phpMyAdmin_folder = 'phpmyadmin'
} elsif $::osfamily == 'redhat' {
$phpMyAdmin_package = 'phpMyAdmin.noarch'
$phpMyAdmin_folder = 'phpMyAdmin'
}
if ! defined(Package[$phpMyAdmin_package]) {
package { $phpMyAdmin_package:
require => Class['mysql::server']
}
}
include puphpet::params
if is_hash($apache_values) {
$mysql_webroot_location = $puphpet::params::apache_webroot_location
} elsif is_hash($nginx_values) {
$mysql_webroot_location = $puphpet::params::nginx_webroot_location
mysql_nginx_default_conf { 'override_default_conf':
webroot => $mysql_webroot_location
}
}
file { "${mysql_webroot_location}/phpmyadmin":
target => "/usr/share/${phpMyAdmin_folder}",
ensure => link,
replace => 'no',
require => [
Package[$phpMyAdmin_package],
File[$mysql_webroot_location]
]
}
}
define mysql_nginx_default_conf (
$webroot
) {
if $php5_fpm_sock == undef {
$php5_fpm_sock = '/var/run/php5-fpm.sock'
}
if $fastcgi_pass == undef {
$fastcgi_pass = $php_values['version'] ? {
undef => null,
'53' => '127.0.0.1:9000',
default => "unix:${php5_fpm_sock}"
}
}
class { 'puphpet::nginx':
fastcgi_pass => $fastcgi_pass,
notify => Class['nginx::service'],
}
}

View File

@ -0,0 +1,36 @@
#!/bin/bash
OS=$(/bin/bash /vagrant/shell/os-detect.sh ID)
CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME)
if [[ ! -d /.puphpet-stuff ]]; then
cat /vagrant/shell/self-promotion.txt
mkdir /.puphpet-stuff
echo "Created directory /.puphpet-stuff"
fi
if [[ ! -f /.puphpet-stuff/initial-setup-repo-update ]]; then
if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then
echo "Running initial-setup apt-get update"
apt-get update >/dev/null
touch /.puphpet-stuff/initial-setup-repo-update
echo "Finished running initial-setup apt-get update"
elif [[ "$OS" == 'centos' ]]; then
echo "Running initial-setup yum update"
yum update -y >/dev/null
echo "Finished running initial-setup yum update"
echo "Installing basic development tools (CentOS)"
yum -y groupinstall "Development Tools" >/dev/null
echo "Finished installing basic development tools (CentOS)"
touch /.puphpet-stuff/initial-setup-repo-update
fi
fi
if [[ "$OS" == 'ubuntu' && ("$CODENAME" == 'lucid' || "$CODENAME" == 'precise') && ! -f /.puphpet-stuff/ubuntu-required-libraries ]]; then
echo 'Installing basic curl packages (Ubuntu only)'
apt-get install -y libcurl3 libcurl4-gnutls-dev >/dev/null
echo 'Finished installing basic curl packages (Ubuntu only)'
touch /.puphpet-stuff/ubuntu-required-libraries
fi

View File

@ -0,0 +1,82 @@
#!/bin/bash
OS=$(/bin/bash /vagrant/shell/os-detect.sh ID)
CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME)
# Directory in which librarian-puppet should manage its modules directory
PUPPET_DIR=/etc/puppet/
$(which git > /dev/null 2>&1)
FOUND_GIT=$?
if [ "$FOUND_GIT" -ne '0' ] && [ ! -f /.puphpet-stuff/librarian-puppet-installed ]; then
$(which apt-get > /dev/null 2>&1)
FOUND_APT=$?
$(which yum > /dev/null 2>&1)
FOUND_YUM=$?
echo 'Installing git'
if [ "${FOUND_YUM}" -eq '0' ]; then
yum -q -y makecache
yum -q -y install git
else
apt-get -q -y install git-core >/dev/null
fi
echo 'Finished installing git'
fi
if [[ ! -d "$PUPPET_DIR" ]]; then
mkdir -p "$PUPPET_DIR"
echo "Created directory $PUPPET_DIR"
fi
cp "/vagrant/puppet/Puppetfile" "$PUPPET_DIR"
echo "Copied Puppetfile"
if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then
if [[ ! -f /.puphpet-stuff/librarian-base-packages ]]; then
echo 'Installing base packages for librarian'
apt-get install -y build-essential ruby-dev >/dev/null
echo 'Finished installing base packages for librarian'
touch /.puphpet-stuff/librarian-base-packages
fi
fi
if [ "$OS" == 'ubuntu' ]; then
if [[ ! -f /.puphpet-stuff/librarian-libgemplugin-ruby ]]; then
echo 'Updating libgemplugin-ruby (Ubuntu only)'
apt-get install -y libgemplugin-ruby >/dev/null
echo 'Finished updating libgemplugin-ruby (Ubuntu only)'
touch /.puphpet-stuff/librarian-libgemplugin-ruby
fi
if [ "$CODENAME" == 'lucid' ] && [ ! -f /.puphpet-stuff/librarian-rubygems-update ]; then
echo 'Updating rubygems (Ubuntu Lucid only)'
echo 'Ignore all "conflicting chdir" errors!'
gem install rubygems-update >/dev/null
/var/lib/gems/1.8/bin/update_rubygems >/dev/null
echo 'Finished updating rubygems (Ubuntu Lucid only)'
touch /.puphpet-stuff/librarian-rubygems-update
fi
fi
if [[ ! -f /.puphpet-stuff/librarian-puppet-installed ]]; then
echo 'Installing librarian-puppet'
gem install librarian-puppet >/dev/null
echo 'Finished installing librarian-puppet'
echo 'Running initial librarian-puppet'
cd "$PUPPET_DIR" && librarian-puppet install --clean >/dev/null
echo 'Finished running initial librarian-puppet'
touch /.puphpet-stuff/librarian-puppet-installed
else
echo 'Running update librarian-puppet'
cd "$PUPPET_DIR" && librarian-puppet update >/dev/null
echo 'Finished running update librarian-puppet'
fi

View File

@ -0,0 +1,49 @@
#!/bin/bash
# Try and get debian operating system
# id, codename, and release
TYPE=$(echo "$1" | tr '[A-Z]' '[a-z]')
OS=$(uname)
ID="unknown"
CODENAME="unknown"
RELEASE="unknown"
if [ "$OS" == "Linux" ]; then
# detect centos
grep "centos" /etc/issue -i -q
if [ $? = '0' ]; then
ID="centos"
RELEASE=$(cat /etc/redhat-release | grep -o 'release [0-9]' | cut -d " " -f2)
# could be debian or ubuntu
elif [ $(which lsb_release) ]; then
ID=$(lsb_release -i | cut -f2)
CODENAME=$(lsb_release -c | cut -f2)
RELEASE=$(lsb_release -r | cut -f2)
elif [ -f "/etc/lsb-release" ]; then
ID=$(cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2)
CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d "=" -f2)
RELEASE=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2)
elif [ -f "/etc/issue" ]; then
ID=$(head -1 /etc/issue | cut -d " " -f1)
if [ -f "/etc/debian_version" ]; then
RELEASE=$(</etc/debian_version)
else
RELEASE=$(head -1 /etc/issue | cut -d " " -f2)
fi
fi
fi
declare -A info
info[id]=$(echo "$ID" | tr '[A-Z]' '[a-z]')
info[codename]=$(echo "$CODENAME" | tr '[A-Z]' '[a-z]')
info[release]=$(echo "$RELEASE" | tr '[A-Z]' '[a-z]')
if [ "$TYPE" ] ; then
echo "${info[$TYPE]}"
else
echo -e "ID\t${info[id]}"
echo -e "CODENAME\t${info[codename]}"
echo -e "RELEASE\t${info[release]}"
fi

View File

@ -0,0 +1,7 @@
____ ____ _ _ ____ _ generated using
| _ \ _ _| _ \| | | | _ \ ___| |_ ___ ___ _ __ ___
| |_) | | | | |_) | |_| | |_) / _ \ __| / __/ _ \| '_ ` _ \
| __/| |_| | __/| _ | __/ __/ |_ | (_| (_) | | | | | |
|_| \__,_|_| |_| |_|_| \___|\__(_)___\___/|_| |_| |_|

View File

@ -0,0 +1,43 @@
#!/bin/bash
OS=$(/bin/bash /vagrant/shell/os-detect.sh ID)
RELEASE=$(/bin/bash /vagrant/shell/os-detect.sh RELEASE)
CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME)
if [[ ! -f /.puphpet-stuff/update-puppet ]]; then
if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then
echo "Downloading http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb"
wget --quiet --tries=5 --timeout=10 -O "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" "http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb"
echo "Finished downloading http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb"
dpkg -i "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" >/dev/null
echo "Running update-puppet apt-get update"
apt-get update >/dev/null
echo "Finished running update-puppet apt-get update"
echo "Updating Puppet to latest version"
apt-get -y install puppet >/dev/null
PUPPET_VERSION=$(puppet help | grep 'Puppet v')
echo "Finished updating puppet to latest version: $PUPPET_VERSION"
touch /.puphpet-stuff/update-puppet
echo "Created empty file /.puphpet-stuff/update-puppet"
elif [ "$OS" == 'centos' ]; then
echo "Downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm"
yum -y --nogpgcheck install "http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm" >/dev/null
echo "Finished downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm"
echo "Running update-puppet yum update"
yum -y update >/dev/null
echo "Finished running update-puppet yum update"
echo "Installing/Updating Puppet to latest version"
yum -y install puppet >/dev/null
PUPPET_VERSION=$(puppet help | grep 'Puppet v')
echo "Finished installing/updating puppet to latest version: $PUPPET_VERSION"
touch /.puphpet-stuff/update-puppet
echo "Created empty file /.puphpet-stuff/update-puppet"
fi
fi