-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Refactor module #3
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Make sure you have purge_configs set to false in your apache class! | ||
# | ||
class puppetboard::apache::conf ( | ||
$wsgi_alias = '/puppetboard', | ||
$threads = 5, | ||
$user = $::puppetboard::params::user, | ||
$group = $::puppetboard::params::group, | ||
) inherits ::puppetboard::params { | ||
|
||
$docroot = "/home/${user}/puppetboard" | ||
|
||
file { "${docroot}/wsgi.py": | ||
ensure => present, | ||
content => template('puppetboard/wsgi.py.erb'), | ||
owner => $user, | ||
group => $group, | ||
require => User[$user], | ||
} | ||
|
||
file { "${::puppetboard::params::apache_confd}/puppetboard.conf": | ||
ensure => present, | ||
owner => 'root', | ||
group => 'root', | ||
content => template('puppetboard/apache/conf.erb'), | ||
require => File["${docroot}/wsgi.py"], | ||
notify => Service[$::puppetboard::params::apache_service], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class puppetboard::apache::vhost ( | ||
$vhost_name, | ||
$port = 5000, | ||
$threads = 5, | ||
$user = $::puppetboard::params::user, | ||
$group = $::puppetboard::params::group, | ||
) inherits ::puppetboard::params { | ||
|
||
$docroot = "/home/${user}/puppetboard", | ||
|
||
$wsgi_script_aliases = { | ||
'/' => "${docroot}/wsgi.py", | ||
} | ||
|
||
$wsgi_daemon_process_options = { | ||
threads => $threads, | ||
group => $group, | ||
user => $user, | ||
} | ||
|
||
file { "${docroot}/wsgi.py": | ||
ensure => present, | ||
content => template('puppetboard/wsgi.py.erb'), | ||
owner => $user, | ||
group => $group, | ||
require => User[$user], | ||
} | ||
|
||
::apache::vhost { $vhost_name: | ||
port => $port, | ||
docroot => $docroot, | ||
wsgi_daemon_process => $user, | ||
wsgi_process_group => $group, | ||
wsgi_script_aliases => $wsgi_script_aliases, | ||
wsgi_daemon_process_options => $wsgi_daemon_process_options, | ||
require => File["${docroot}/wsgi.py"], | ||
notify => Service[$::puppetboard::params::apache_service], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,49 @@ | ||
# == Class: puppetboard | ||
# | ||
# Full description of class puppetboard here. | ||
# Base class for Puppetboard. | ||
# Sets up the user and python environment. | ||
# | ||
# You should also use one of the apache classes as well. | ||
# | ||
# === Parameters | ||
# | ||
# Document parameters here. | ||
# | ||
# [*sample_parameter*] | ||
# Explanation of what this parameter affects and what it defaults to. | ||
# e.g. "Specify one or more upstream ntp servers as an array." | ||
# | ||
# === Variables | ||
# [*user*] | ||
# Puppetboard system user. | ||
# Defaults to 'puppetboard' | ||
# | ||
# Here you should define a list of variables that this module would require. | ||
# | ||
# [*sample_variable*] | ||
# Explanation of how this variable affects the funtion of this class and if it | ||
# has a default. e.g. "The parameter enc_ntp_servers must be set by the | ||
# External Node Classifier as a comma separated list of hostnames." (Note, | ||
# global variables should not be used in preference to class parameters as of | ||
# Puppet 2.6.) | ||
# [*experimental*] | ||
# Enable experimental features. | ||
# Defaults to true | ||
# | ||
# === Examples | ||
# | ||
# class { puppetboard: | ||
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ] | ||
# class { 'puppetboard': | ||
# user => 'pboard', | ||
# group => 'pboard', | ||
# } -> | ||
# class { 'puppetboard::apache::conf': | ||
# user => 'pboard', | ||
# group => 'pboard', | ||
# } | ||
# | ||
# === Authors | ||
# | ||
# Author Name <[email protected]> | ||
# | ||
# === Copyright | ||
# | ||
# Copyright 2013 Your name here, unless otherwise noted. | ||
# | ||
class puppetboard( | ||
$user = 'puppetboard', # The user to run puppetboard as | ||
$mode = 'dev', # also can run it under mod_wsgi | ||
$listen = '127.0.0.1', # listen locally or globally | ||
$experimental = 'true', # enable experimental features | ||
$port = '5000', | ||
$manage_packages = 'true', | ||
$manage_apache_service = 'true', | ||
) { | ||
$user = $::puppetboard::params::user, | ||
$group = $::puppetboard::params::group, | ||
$experimental = true, | ||
) inherits ::puppetboard::params { | ||
|
||
class { 'python': | ||
version => 'system', | ||
dev => true, | ||
virtualenv => true, | ||
} | ||
|
||
if $manage_packages == 'true' { | ||
package { 'dtach': | ||
ensure => present, | ||
} | ||
} | ||
|
||
group { 'puppetboard': | ||
group { $group: | ||
ensure => present, | ||
} | ||
|
||
user { $user: | ||
ensure => present, | ||
home => "/home/${user}", | ||
shell => '/bin/bash', | ||
managehome => true, | ||
gid => 'puppetboard', | ||
require => Group['puppetboard'], | ||
gid => $group, | ||
require => Group[$group], | ||
} | ||
|
||
vcsrepo { "/home/${user}/puppetboard": | ||
|
@@ -106,7 +82,7 @@ | |
} | ||
} | ||
|
||
if $experimental == 'true' { | ||
if ($experimental) { | ||
file_line { 'puppetboard experimental': | ||
path => "/home/${user}/puppetboard/puppetboard/default_settings.py", | ||
line => 'PUPPETDB_EXPERIMENTAL=True', | ||
|
@@ -119,56 +95,4 @@ | |
} | ||
} | ||
|
||
if $mode == 'dev' { | ||
|
||
notify { "not starting puppetboard in dev mode": } | ||
|
||
} | ||
|
||
if $mode == 'wsgi' { | ||
|
||
case $::osfamily { | ||
'Debian': { | ||
$apache_root = '/etc/apache2/sites-enabled' | ||
$apache_service = 'apache2' | ||
} | ||
'RedHat': { | ||
$apache_root = '/etc/httpd/conf.d' | ||
$apache_service = 'httpd' | ||
} | ||
default: { fail("This module is not supported on ${::osfamily}") } | ||
} | ||
|
||
if $manage_packages == 'true' { | ||
package { 'libapache2-mod-wsgi': | ||
ensure => present, | ||
} | ||
} | ||
|
||
|
||
file { "/home/${user}/puppetboard/wsgi.py": | ||
ensure => present, | ||
content => template('puppetboard/wsgi.py.erb'), | ||
owner => $user, | ||
group => 'puppetboard', | ||
notify => Service[$apache_service], | ||
} | ||
|
||
|
||
file { "${apache_root}/puppetboard": | ||
ensure => present, | ||
content => template('puppetboard/puppetboard.erb'), | ||
owner => $user, | ||
group => 'puppetboard', | ||
notify => Service[$apache_service], | ||
} | ||
|
||
if $manage_apache_service == 'true' { | ||
service { $apache_service: | ||
ensure => running, | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class puppetboard::params { | ||
|
||
case $::osfamily { | ||
'Debian': { | ||
$apache_confd = '/etc/apache2/conf.d' | ||
$apache_service = 'apache2' | ||
} | ||
'RedHat': { | ||
$apache_confd = '/etc/httpd/conf.d' | ||
$apache_service = 'httpd' | ||
} | ||
} | ||
|
||
$user = 'puppetboard' | ||
$group = 'puppetboard' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
WSGIDaemonProcess puppetboard user=<%= @user -%> group=<%= @user -%> threads=<%= @threads %> | ||
WSGIScriptAlias <%= @wsgi_alias -%> <%= @docroot -%>/wsgi.py | ||
|
||
<Directory <%= @docroot -%>> | ||
WSGIProcessGroup <%= @user %> | ||
WSGIApplicationGroup %{GLOBAL} | ||
Order deny,allow | ||
Allow from all | ||
</Directory> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're a hero for filling in the topdocs.