diff --git a/manifests/init.pp b/manifests/init.pp index 0b63fcfc..079933fe 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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*] @@ -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 @@ -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, @@ -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: @@ -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', diff --git a/manifests/params.pp b/manifests/params.pp index e2bfbb10..4559e523 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' } diff --git a/templates/default_settings.py.erb b/templates/default_settings.py.erb deleted file mode 100644 index d48642f0..00000000 --- a/templates/default_settings.py.erb +++ /dev/null @@ -1,13 +0,0 @@ -PUPPETDB_HOST = '<%= @puppetdb_host %>' -PUPPETDB_PORT = <%= @puppetdb_port %> -PUPPETDB_SSL_VERIFY = <%= @puppetdb_ssl %> -PUPPETDB_KEY = '<%= @puppetdb_key %>' -PUPPETDB_CERT = '<%= @puppetdb_cert %>' -PUPPETDB_TIMEOUT = <%= @puppetdb_timeout %> -DEV_LISTEN_HOST = '<%= @dev_listen_host %>' -DEV_LISTEN_PORT = <%= @dev_listen_port %> -UNRESPONSIVE_HOURS = <%= @unresponsive %> -ENABLE_QUERY = <%= @enable_query %> -LOCALISE_TIMESTAMP = <%= @localise_timestamp %> -LOGLEVEL = '<%= @python_loglevel %>' -PUPPETDB_EXPERIMENTAL = <%= @experimental %> diff --git a/templates/settings.py.erb b/templates/settings.py.erb new file mode 100644 index 00000000..58ded934 --- /dev/null +++ b/templates/settings.py.erb @@ -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 -%> diff --git a/templates/wsgi.py.erb b/templates/wsgi.py.erb index a7e338b4..3bf4ab67 100644 --- a/templates/wsgi.py.erb +++ b/templates/wsgi.py.erb @@ -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))