Skip to content

Pahoughton test #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
12bca7b
basic testing.
pahoughton Mar 27, 2014
d73a8c7
cleanup for puppet lint.
pahoughton Mar 27, 2014
249b921
Merge branch 'master' into pahoughton-devel
pahoughton May 9, 2014
aac471f
On ubuntu, the package needs to be installed to create /etc/php5 dir
pahoughton May 9, 2014
8b889f7
on ubuntu, the package is required before the ini because the package
pahoughton May 9, 2014
751c66f
wip - notify php-fpm (bounce) when modules are installed.
pahoughton May 9, 2014
c0f034b
cleanup for puppet-lint.
pahoughton May 9, 2014
fe9fc02
i use emacs
pahoughton May 9, 2014
92df917
rspec unit tests
pahoughton May 9, 2014
2470bc4
rspec unittests pass
pahoughton May 9, 2014
1cec0dd
first attempt travis-ci.
pahoughton May 9, 2014
e092c51
ping travis
pahoughton May 10, 2014
4935abb
cleanup.
pahoughton May 10, 2014
a83d817
next travis test.
pahoughton May 10, 2014
6f13546
travis next attempt
pahoughton May 10, 2014
17dd32f
travis testing
pahoughton May 10, 2014
1a6ef5b
fix rspec-puppet version
pahoughton May 10, 2014
4d98851
Add librarian-puppet
pahoughton May 10, 2014
e2aec78
librarian puppet on if needed.
pahoughton May 10, 2014
c741861
rework tasks
pahoughton May 10, 2014
53c1a61
Add travis-ci test status.
pahoughton May 10, 2014
bfd628f
cleanup
pahoughton May 13, 2014
09c763f
use scope to get values from param
pahoughton May 16, 2014
3bc7db8
change back to include params
pahoughton May 16, 2014
cae8b4a
change back to include params
pahoughton May 16, 2014
d033769
notify fpm about changes
pahoughton May 16, 2014
e13ec0b
simple nginx/php-fmp shortcut
pahoughton May 16, 2014
788504e
Merge branch 'pahoughton-devel' into pahoughton-test
pahoughton May 16, 2014
8161176
fix - support arg and default value from param.
pahoughton May 16, 2014
1b8f225
add unittesting for php::fpm
pahoughton May 16, 2014
d298f00
oops
pahoughton May 16, 2014
a5a2195
improvement - now php::module { pgsql : } can be in multiple objects.
pahoughton May 16, 2014
7c81240
more to ignore
pahoughton May 17, 2014
1a143f2
remove php::ini - conflicts
pahoughton Jun 3, 2014
036f72d
rename port var to php-fpm for consistency
pahoughton Jun 4, 2014
9f35aa6
fix static patter causes issues w/ non-php apps
pahoughton Jun 23, 2014
cc58d55
Merge branch 'pahoughton-devel' into pahoughton-test
pahoughton Jun 23, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
.librarian/
.tmp/
Puppetfile.lock
list/
Gemfile.lock
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .travis.yml - 2014-05-10 03:03
#
# Copyright (c) 2014 Paul Houghton <[email protected]>

language: ruby
notifications:
email:
- [email protected]

rvm:
- 1.9.3
- 2.0.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.4.3"
- PUPPET_GEM_VERSION="~> 3.5.1"
script: "bundle exec rake -t lint unittest_prep unittest_suite"
20 changes: 20 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Gemfile - 2014-05-10 03:03
#
# Copyright (c) 2014 Paul Houghton <[email protected]>
#
source 'https://rubygems.org'

group :development, :test do
gem 'bundler'
gem 'builder','~>3.2.2'
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet'
gem 'librarian-puppet'
gem 'puppet-lint', '~> 0.3.2'
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
9 changes: 9 additions & 0 deletions Puppetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Puppetfile - 2014-05-15 03:27
#
# Copyright (c) 2014 Paul Houghton <[email protected]>
#
forge "http://forge.puppetlabs.com"

mod 'pahoughton/nginx',
:git => 'http://github.com/pahoughton/puppet-nginx',
:ref => 'pahoughton-devel'
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# puppet-php
# puppet-php [![Build Status](https://travis-ci.org/pahoughton/puppet-php.png)](https://travis-ci.org/pahoughton/puppet-php)

## Overview

Expand Down Expand Up @@ -88,4 +88,3 @@ Then from the nginx configuration :
include /etc/nginx/fastcgi.conf;
fastcgi_pass wwwbackend;
}

65 changes: 65 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Rakefile - 2014-03-27 06:45
#
# Copyright (c) 2014 Paul Houghton <[email protected]>
#

require 'rake'
require 'rspec/core/rake_task'
require 'puppet-lint/tasks/puppet-lint'

PuppetLint.configuration.disable_80chars
PuppetLint.configuration.disable_class_parameter_defaults
PuppetLint.configuration.ignore_paths = FileList['**/fixtures/modules/**/**']

desc "Test prep with librarian-puppet"
task :unittest_prep do
sh "
if [ -f Puppetfile ] ; then
if [ -d .librarian ] ; then
echo updating...
librarian-puppet update;
else
echo installing...
librarian-puppet install --path=spec/fixtures/modules/;
fi
fi
"
end

desc "Unit tests"
RSpec::Core::RakeTask.new(:unittest) do |t|
t.pattern = 'spec/unit/**/*_spec.rb'
end

desc "Unit tests"
RSpec::Core::RakeTask.new(:unittest_doc) do |t|
t.rspec_opts = ['--format=d']
t.pattern = 'spec/unit/**/*_spec.rb'
end

desc "Unit-suite tests w/o doc"
RSpec::Core::RakeTask.new(:unittest_nodoc) do |t|
t.pattern = 'spec/unit-suite/**/*_spec.rb'
end

desc "Unit-suite tests w/o doc"
RSpec::Core::RakeTask.new(:unittest_suite) do |t|
t.rspec_opts = ['--format=d']
t.pattern = 'spec/unit-suite/**/*_spec.rb'
end

desc "Unit-suite tests w/ doc"
RSpec::Core::RakeTask.new(:unittest_fulldoc) do |t|
t.rspec_opts = ['--format=d','--out=unittest-suite-results.txt']
t.pattern = 'spec/unit-suite/**/*_spec.rb'
end

desc "Generate test results markdown"
task :unittest_md => [:unittest_fulldoc] do
sh "outfn=unittest-suite-results.md;
echo '## 'Unit test results - `date` > $outfn;
echo '```' >> $outfn;
cat unittest-suite-results.txt >> $outfn;
echo '```' >> $outfn;
"
end
19 changes: 12 additions & 7 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
# include php::cli
#
class php::cli (
$ensure = 'installed',
$inifile = '/etc/php.ini',
$cli_package_name = $::php::params::cli_package_name,
) inherits ::php::params {
package { $cli_package_name:
$ensure = 'installed',
$inifile = '/etc/php.ini',
$package = undef,
) {

include '::php::params'

$cli_package_name = $package ? {
undef => $::php::params::cli_package_name,
default => $package,
}
package { $cli_package_name :
ensure => $ensure,
require => File[$inifile],
}
}

7 changes: 5 additions & 2 deletions manifests/common.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#
# We can't use a virtual resource, since we have no central place to put it.
#
class php::common inherits ::php::params {
package { $common_package_name: ensure => 'installed' }
class php::common {

include '::php::params'

package { $::php::params::common_package_name: ensure => 'installed' }
}
128 changes: 128 additions & 0 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# fpm.pp - 2014-02-19 07:36
#
# Copyright (c) 2014 Paul Houghton <[email protected]>
#
class php::fpm(
$wwwdir = undef,
$php_modules = undef,
$appuser = undef,
$appgroup = undef,
$port = undef,
$vhost = 'localhost',
) {

include '::php::params'

$directories = hiera('directories',{'www' => '/srv/www'})
$groups = hiera('groups',{'www' => {'RedHat'=>'nginx','Debian'=>'www-data'}})
$ports = hiera('ports',{'php-fpm' => '9000'})
$users = hiera('users', { 'git' => 'git', 'gitlab' => 'git','www' => {'RedHat'=>'nginx','Debian'=>'www-data'} })

$basedir = $wwwdir ? {
undef => $directories['www'],
default => $wwwdir,
}
$user = $appuser ? {
undef => $users['www'][$::osfamily],
default => $appuser,
}
$group = $appgroup ? {
undef => $groups['www'][$::osfamily],
default => $appgroup,
}
$pxyport = $port ? {
undef => $ports['php-fpm'],
default => $port,
}

File {
owner => $user,
group => $group,
}

if $::osfamily == 'Debian' {
php::ini { '/etc/php5/fpm/php.ini':
display_errors => 'On',
short_open_tag => 'Off',
date_timezone => 'America/Denver',
require => Package[$::php::params::fpm_package_name],
}
}
if ! defined(Class['php::cli']) {
class { 'php::cli' : }
}
class { 'php::fpm::daemon' : }

php::fpm::conf { 'www' :
listen => "127.0.0.1:${pxyport}",
user => $user,
group => $group,
require => User[$user],
}
if $php_modules {
php::module { $php_modules : }
}
$php_base_dir = $::osfamily ? {
'Debian' => '/var/lib/php5',
default => '/var/lib/php',
}
file { [$php_base_dir, "${php_base_dir}/session"] :
ensure => 'directory',
mode => '0775',
require => User[$user],
}

if $basedir {
file { "${basedir}/phpinfo.php" :
ensure => 'file',
content => "<?php phpinfo(); ?>\n",
require => File[$basedir],
}
}
if ! defined(Class['nginx']) and $basedir {
class { 'nginx' : }
ensure_resource('file',$basedir,{
ensure => 'directory',
owner => $user,
group => $group,
mode => '0775',
require => Class['nginx'],
})
if $vhost {
nginx::resource::vhost { $vhost :
ensure => 'present',
www_root => $basedir,
}
}
}

if $vhost and $basedir {
nginx::resource::location { 'php':
ensure => 'present',
vhost => $vhost,
location => '~ \.php$',
www_root => $basedir,
index_files => undef,
proxy => undef,
fastcgi => "127.0.0.1:${pxyport}",
}

if $::selinux == 'true' {
ensure_resource('selboolean','httpd_can_network_connect',{
value => 'on',
})
# odd, this came up w/ fedora 20 port != 9000
ensure_resource('selboolean','nis_enabled',{
value => 'on',
})
}
# nginx::resource::location { 'static files':
# ensure => 'present',
# vhost => $vhost,
# location => '~ \.(css|gif|jpg|js|png|html)$',
# www_root => $basedir,
# index_files => ['index.php','index.html',],
# proxy => undef,
# }
}
}
4 changes: 1 addition & 3 deletions manifests/fpm/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@
if ( $ensure == 'absent' ) {

file { "${php::params::fpm_pool_dir}/${pool}.conf":
notify => Service[$php::params::fpm_service_name],
ensure => absent,
notify => Service[$php::params::fpm_service_name],
require => Package[$php::params::fpm_package_name],
}

} else {

file { "${php::params::fpm_pool_dir}/${pool}.conf":
notify => Service[$php::params::fpm_service_name],
content => template('php/fpm/pool.conf.erb'),
Expand All @@ -86,4 +85,3 @@
}

}

35 changes: 16 additions & 19 deletions manifests/fpm/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,41 @@
$log_owner = 'root',
$log_group = false,
$log_dir_mode = '0770',
) inherits ::php::params {
) {

include '::php::params'

# Hack-ish to default to user for group too
$log_group_final = $log_group ? {
false => $log_owner,
default => $log_group,
}

package { $fpm_package_name: ensure => $ensure }
package { $::php::params::fpm_package_name: ensure => $ensure }

if ( $ensure != 'absent' ) {
service { $fpm_service_name:
ensure => running,
enable => true,
restart => "service ${fpm_service_name} reload",
hasstatus => true,
require => Package[$fpm_package_name],
}

file { "${::php::params::fpm_conf_dir}/php-fpm.conf":
notify => Service[$::php::params::fpm_service_name],
content => template('php/fpm/php-fpm.conf.erb'),
require => Package[$::php::params::fpm_package_name],
}
# When running FastCGI, we don't always use the same user
file { '/var/log/php-fpm':
ensure => directory,
owner => $log_owner,
group => $log_group_final,
mode => $log_dir_mode,
require => Package[$fpm_package_name],
require => Package[$::php::params::fpm_package_name],
}

file { "${fpm_conf_dir}/php-fpm.conf":
notify => Service[$fpm_service_name],
content => template('php/fpm/php-fpm.conf.erb'),
owner => 'root',
group => 'root',
mode => 0644,
require => Package[$fpm_package_name],
service { $::php::params::fpm_service_name:
ensure => running,
enable => true,
restart => "service ${::php::params::fpm_service_name} reload",
hasstatus => true,
require => Package[$::php::params::fpm_package_name],
}

}

}

6 changes: 5 additions & 1 deletion manifests/ini.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,14 @@

include '::php::common'

$ininotify = defined(Class['php::fpm::daemon']) ? {
true => Service[$php::params::fpm_service_name],
default => undef,
}
file { $title:
ensure => $ensure,
content => template($template),
notify => $ininotify,
}

}

Loading