Skip to content

Commit

Permalink
Merge pull request #42 from rmnwolf/Issue41
Browse files Browse the repository at this point in the history
move custom settings into settings.py.
  • Loading branch information
Daniele Sluijters committed Jun 19, 2014
2 parents 1a15966 + a7da635 commit 99927a3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 45 deletions.
62 changes: 34 additions & 28 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
# Defaults to 3 ($::puppetboard::params::unresponsive)
#
# [*enable_query*]
# (string) Whether to allow the user to run raw queries against PuppetDB. 'True' or 'False'.
# (bool) Whether to allow the user to run raw queries against PuppetDB.
# Defaults to 'True' ($::puppetboard::params::enable_query)
#
# [*localise_timestamp*]
# (string) Whether to localise the timestamps in the UI. 'True' or 'False'.
# (bool) Whether to localise the timestamps in the UI.
# Defaults to 'True' ($::puppetboard::params::localise_timestamp)
#
# [*python_loglevel*]
Expand All @@ -78,13 +78,16 @@
# Defaults to false ($::puppetboard::params::python_proxy)
#
# [*experimental*]
# (string) Enable experimental features. 'True' or 'False'.
# (bool) Enable experimental features.
# Defaults to true ($::puppetboard::params::experimental)
#
# [*revision*]
# (string) Commit, tag, or branch from Puppetboard's Git repo to be used
# Defaults to undef, meaning latest commit will be used ($::puppetboard::params::revision)
#
# [*reports_count*]
# (string) the number of reports to display
#
# [*manage_git*]
# (bool) If true, require the git package. If false do nothing.
# Defaults to false
Expand Down Expand Up @@ -119,7 +122,8 @@
$group = $::puppetboard::params::group,
$basedir = $::puppetboard::params::basedir,
$git_source = $::puppetboard::params::git_source,

$dev_listen_host = $::puppetboard::params::dev_listen_host,
$dev_listen_port = $::puppetboard::params::dev_listen_port,
$puppetdb_host = $::puppetboard::params::puppetdb_host,
$puppetdb_port = $::puppetboard::params::puppetdb_port,
$puppetdb_key = $::puppetboard::params::puppetdb_key,
Expand All @@ -133,12 +137,16 @@
$python_proxy = $::puppetboard::params::python_proxy,
$experimental = $::puppetboard::params::experimental,
$revision = $::puppetboard::params::revision,
$reports_count = $::puppetboard::params::reports_count,
$manage_user = true,
$manage_group = true,
$manage_git = false,
$manage_virtualenv = false,

) inherits ::puppetboard::params {
validate_bool($enable_query)
validate_bool($experimental)
validate_bool($localise_timestamp)

if $manage_group {
group { $group:
Expand Down Expand Up @@ -178,32 +186,30 @@
recurse => true,
}

# Template Uses:
# - $puppetdb_host
# - $puppetdb_port
# - $puppetdb_ssl
# - $puppetdb_key
# - $puppetdb_cert
# - $puppetdb_timeout
# - $dev_listen_host
# - $dev_listen_port
# - $unresponsive
# - $enable_query
# - $localise_timestamp
# - $python_loglevel
# - $experimental
file { 'puppetboard/default_settings.py':
path => "${basedir}/puppetboard/puppetboard/default_settings.py",
owner => $user,
group => $group,
mode => '0644',
content => template('puppetboard/default_settings.py.erb'),
require => [
File["${basedir}/puppetboard"],
Python::Virtualenv["${basedir}/virtenv-puppetboard"]
],
#Template consumes:
#$dev_listen_host
#$dev_listen_port
#$enable_query
#$experimental
#$localise_timestamp
#$python_loglevel
#$puppetdb_cert
#$puppetdb_host
#$puppetdb_key
#$puppetdb_port
#$puppetdb_ssl_verify
#$puppetdb_timeout
#$unresponsive
file {"${basedir}/puppetboard/settings.py":
ensure => 'file',
group => $group,
mode => '0644',
owner => $user,
content => template('puppetboard/settings.py.erb'),
require => Vcsrepo["${basedir}/puppetboard"],
}


python::virtualenv { "${basedir}/virtenv-puppetboard":
ensure => present,
version => 'system',
Expand Down
9 changes: 5 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
$puppetdb_host = 'localhost'
$puppetdb_port = 8080
$puppetdb_key = 'None'
$puppetdb_ssl = 'False'
$puppetdb_ssl = false
$puppetdb_cert = 'None'
$puppetdb_timeout = 20
$dev_listen_host = '127.0.0.1'
$dev_listen_port = 5000
$unresponsive = 3
$enable_query = 'True'
$localise_timestamp = 'True'
$enable_query = true
$localise_timestamp = true
$python_loglevel = 'info'
$python_proxy = false
$experimental = 'False'
$reports_count = '10'
$experimental = false
$revision = undef
$virtualenv = 'python-virtualenv'
}
13 changes: 0 additions & 13 deletions templates/default_settings.py.erb

This file was deleted.

47 changes: 47 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<% if @dev_listen_host -%>
DEV_LISTEN_HOST = '<%= @dev_listen_host %>'
<% end -%>
<% if @dev_listen_port -%>
DEV_LISTEN_PORT = <%= @dev_listen_port %>
<% end -%>
<% if @python_loglevel -%>
LOGLEVEL = '<%= @python_loglevel-%>'
<% end -%>
<% if @puppetdb_host -%>
PUPPETDB_HOST = '<%= @puppetdb_host %>'
<% end -%>
<% if @puppetdb_port -%>
PUPPETDB_PORT = <%= @puppetdb_port %>
<% end -%>
<% if @puppetdb_ssl_verify -%>
PUPPETDB_SSL_VERIFY = '<%= @puppetdb_ssl_verify %>'
<% else -%>
PUPPETDB_SSL_VERIFY = False
<% end -%>
<% if @puppetdb_key -%>
PUPPETDB_KEY = '<%= @puppetdb_key %>'
<% end-%>
<% if @puppetdb_cert -%>
PUPPETDB_CERT = '<%= @puppetdb_cert %>'
<% end -%>
<% if @puppetdb_timeout -%>
PUPPETDB_TIMEOUT = <%= @puppetdb_timeout %>
<% end -%>
<% if @unresponsive -%>
UNRESPONSIVE_HOURS = <%= @unresponsive %>
<% end -%>
<% if @enable_query -%>
ENABLE_QUERY = True
<% else -%>
ENABLE_QUERY = False
<% end -%>
<% if @localise_timestamp -%>
LOCALISE_TIMESTAMP = True
<% else -%>
LOCALISE_TIMESTAMP = False
<% end -%>
<% if @experimental -%>
PUPPETDB_EXPERIMENTAL = True
<% else -%>
PUPPETDB_EXPERIMENTAL = False
<% end -%>
1 change: 1 addition & 0 deletions templates/wsgi.py.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

os.environ['PUPPETBOARD_SETTINGS'] = '<%= @basedir %>/puppetboard/settings.py'
activate_this = '<%= @basedir %>/virtenv-puppetboard/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

Expand Down

0 comments on commit 99927a3

Please sign in to comment.