Commit 598027de by source_reader

working on refactor

parent 5c3b58f7
......@@ -29,6 +29,19 @@ class joule::config {
path => ['/usr/local/pgsql/bin','/usr/bin:/bin'],
require => Postgresql::Server::Db['joule']
}
$dsn = 'joule:joule@localhost:5432/joule'
if $facts['image_type']=='nilm' {
$cmd = "joule admin initialize --dsn=${dsn} --nilmdb=http://localhost/nilmdb"
} else {
$cmd = "joule admin initialize --dsn=${dsn}"
}
exec{'initialize_joule':
command => $cmd,
path => ['/usr/local/bin','/usr/sbin','/bin'],
creates => '/etc/joule/main.conf',
require => Exec['custom_sql']
}
postgresql::server::pg_hba_rule { 'allow remote access for modules':
description => 'allow network access to joule database',
......
# == Class: joule
#
# Install the joule framework
# doc.wattsworth.net/joule
#
# === Authors
#
# John Donnal <donnal@usna.edu>
2#
# === Copyright
#
# Copyright 2017 John Donnal, unless otherwise noted.
#
class joule {
contain joule::install
......
......@@ -10,19 +10,6 @@ class joule::install{
path => ['/usr/local/bin','/usr/bin'],
}
$dsn = 'joule:joule@localhost:5432/joule'
if $facts['nilm'] {
$cmd = "joule admin initialize --dsn=${dsn} --nilmdb=http://localhost/nilmdb"
} else {
$cmd = "joule admin initialize --dsn=${dsn}"
}
exec{'initialize_joule':
command => $cmd,
path => ['/usr/local/bin','/usr/sbin','/bin'],
creates => '/etc/joule/main.conf',
require => Exec['install_joule',
'custom_sql']
}
user{'joule':
ensure => present,
uid => 901,
......
# == Class: joule_labjack
#
# Full description of class joule_labjack here.
#
# === 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
#
# 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 be avoided in favor of class parameters as
# of Puppet 2.6.)
#
# === Examples
#
# class { 'joule_labjack':
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
# }
#
# === Authors
#
# Author Name <author@domain.com>
#
# === Copyright
#
# Copyright 2018 Your name here, unless otherwise noted.
#
class joule_labjack {
require python
require joule
$pip_url='https://pypi.wattsworth.net/'
$pip_cmd="pip3 install --upgrade --extra-index-url ${pip_url}"
......
......@@ -2,7 +2,7 @@
location /joule/ {
proxy_pass http://unix:/tmp/joule/api:/;
proxy_set_header X-Auth-Required "true";
proxy_http_version 1.1:
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Api-Port "443";
......
class nginx::config{
if $facts['nilm']{
if $facts['image_type']=='nilm'{
$nilmdb = true
notice("nilmdb is true!")
file {'/etc/nginx/nilmdb.conf':
source => 'puppet:///modules/nginx/nilmdb.conf',
owner => root,
group => root,
mode => '0644',
}
} else {
$nilmdb = false
}
file {'/etc/nginx/nginx.conf':
content => template('puppet:///modules/nginx/nginx.conf')
content => template('nginx/nginx.conf.erb'),
owner => root,
group => root,
mode => '0644',
require => Package['nginx'],
}
file {'/etc/nginx/joule.conf':
source => 'puppet:///modules/nginx/joule.conf',
owner => root,
group => root,
mode => '0644',
require => Package['nginx'],
}
file {'/etc/nginx/lumen.conf':
source => 'puppet:///modules/nginx/lumen.conf',
owner => root,
group => root,
mode => '0644',
require => Package['nginx'],
}
file {'/etc/nginx/docs.conf':
source => 'puppet:///modules/nginx/docs.conf',
owner => root,
group => root,
mode => '0644',
}
file {'/etc/nginx/map.conf':
source => 'puppet:///modules/nginx/map.conf',
owner => root,
group => root,
mode => '0644',
require => Package['nginx'],
}
}
......@@ -69,15 +69,15 @@ http {
<% end -%>
}
server{
listen 443;
listen 443 ssl;
include /etc/nginx/lumen.conf;
include /etc/nginx/joule.conf;
<% if @nilmdb -%>
<% if @nilmdb == true -%>
include /etc/nginx/nilmdb.conf;
<% end -%>
# Security configuration
ssl on;
# ssl on;
ssl_certificate /etc/joule/security/server.crt;
ssl_certificate_key /etc/joule/security/server.key;
}
......
# == Class: nilm
# Joule modules for nilm data capture and processing
#
# === Authors
#
# John Donnal <donnal@usna.edu>
#
# === Copyright
#
# Copyright 2017 John Donnal, unless otherwise noted.
#
class nilm {
require python
$pip_url='https://pypi.wattsworth.net/'
$pip_cmd="pip3 install --upgrade --extra-index-url ${pip_url}"
......
......@@ -4,7 +4,7 @@ Description=NilmDB time series database
[Service]
Restart = always
StandardOutput=journal
ExecStartPre = /usr/local/bin/nilmdb-fsck -f -n /opt/data
#ExecStartPre = /usr/local/bin/nilmdb-fsck -f -n /opt/data
ExecStart = /usr/local/bin/uwsgi --ini /etc/nilmdb/nilmdb.ini
[Install]
......
class nilmdb::config{
file{'/etc/nilmdb.ini':
source => "puppet:///nilmdb/nilmdb.ini",
source => "puppet:///modules/nilmdb/nilmdb.ini",
owner => root,
group => root,
mode => '0644',
......@@ -14,7 +14,7 @@ class nilmdb::config{
notify => Service['nilmdb']
}
file{'/etc/systemd/system/nilmdb.service':
source => "puppet:///nilmdb/nilmdb.service",
source => "puppet:///modules/nilmdb/nilmdb.service",
owner => root,
group => root,
mode => '0644'
......
......@@ -22,5 +22,4 @@ class nilmdb {
-> Class['::nilmdb::config']
~> Class['::nilmdb::service']
}
}
......@@ -11,10 +11,10 @@ class nilmdb::install{
}
$pip_url='https://pypi.wattsworth.net/'
$pip_cmd="pip2 install --upgrade --extra-index-url ${pip_url}"
$pip_cmd="pip3 install --upgrade --extra-index-url ${pip_url}"
exec{'install_nilmdb':
command => "${pip_cmd} nilmdb nilmtools",
command => "${pip_cmd} nilmdb",
timeout => 0,
path => ['/usr/local/bin','/usr/bin'],
require => Package[$pip_pkgs]
......@@ -22,8 +22,8 @@ class nilmdb::install{
file{'/opt/data':
ensure => directory,
owner => nilmdb,
group => nilmdb,
owner => joule,
group => joule,
require => User['joule']
}
file{'/etc/nilmdb':
......
# == Class: nilmplug
#
# Install software for WEMO retrofit smart plugs
#
# === Authors
#
# John Donnal <donnal@usna.edu>
#
class nilmplug {
require python
require nilm
$pip_url='https://pypi.wattsworth.net/'
$pip_cmd="pip3 install --upgrade --extra-index-url ${pip_url}"
......
# Class: timescaledb
# ===========================
#
# Full description of class timescaledb here.
#
# Authors
# -------
#
# John Donnal
#
#
class timescaledb {
if $facts['platform'] == 'ubuntu' {
apt::source { 'postgresql':
location => 'http://apt.postgresql.org/pub/repos/apt/',
release => "${lsbdistcodename}-pgdg",
repos => 'main',
key => {
'id' => 'B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8',
'server' => 'hkp://p80.pool.sks-keyservers.net:80'
}
}
apt::ppa {'ppa:timescale/timescaledb-ppa': }
package {'timescaledb-postgresql-10':
ensure => 'present',
require => [Apt::Source['postgresql'], Apt::Ppa['ppa:timescale/timescaledb-ppa']]
}
class{ 'postgresql::server':
}
postgresql::server::config_entry { 'shared_preload_libraries':
value => 'timescaledb',
}
} else {
class{ 'postgresql::globals':
# bindir => '/usr/local/pgsql/bin',
# confdir => '/var/lib/postgresql/10/main',
# datadir => '/var/lib/postgresql/10/main',
version => '11',
# service_name => 'postgresql',
# client_package_name => 'postgresql-9.6',
# psql_path => '/usr/local/pgsql/bin/psql',
}
class{ 'postgresql::server':
# createdb_path => '/usr/local/pgsql/bin/createdb',
# initdb_path => '/usr/local/pgsql/bin/initdb',
# package_ensure => 'absent',
# pg_hba_conf_path => '/var/lib/postgresql/10/main/pg_hba.conf',
# pg_ident_conf_path => '/var/lib/postgresql/10/main/pg_ident.conf',
# postgresql_conf_path => '/var/lib/postgresql/10/main/postgresq.conf',
# psql_path => '/usr/local/pgsql/bin/psql',
#
}
postgresql::server::config_entry { 'shared_preload_libraries':
value => 'timescaledb',
}
}
}
......@@ -20,38 +20,18 @@ class timescaledb {
}
apt::ppa {'ppa:timescale/timescaledb-ppa': }
package {'timescaledb-postgresql-10':
package {'timescaledb-postgresql-11':
ensure => 'present',
require => [Apt::Source['postgresql'], Apt::Ppa['ppa:timescale/timescaledb-ppa']]
}
class{ 'postgresql::server':
}
postgresql::server::config_entry { 'shared_preload_libraries':
value => 'timescaledb',
}
} else {
class{ 'postgresql::globals':
# bindir => '/usr/local/pgsql/bin',
# confdir => '/var/lib/postgresql/10/main',
# datadir => '/var/lib/postgresql/10/main',
version => '11',
# service_name => 'postgresql',
# client_package_name => 'postgresql-9.6',
# psql_path => '/usr/local/pgsql/bin/psql',
}
class{ 'postgresql::server':
# createdb_path => '/usr/local/pgsql/bin/createdb',
# initdb_path => '/usr/local/pgsql/bin/initdb',
# package_ensure => 'absent',
# pg_hba_conf_path => '/var/lib/postgresql/10/main/pg_hba.conf',
# pg_ident_conf_path => '/var/lib/postgresql/10/main/pg_ident.conf',
# postgresql_conf_path => '/var/lib/postgresql/10/main/postgresq.conf',
# psql_path => '/usr/local/pgsql/bin/psql',
#
}
postgresql::server::config_entry { 'shared_preload_libraries':
value => 'timescaledb',
}
}
# timescaledb is compiled manually on the pi
class{ 'postgresql::globals':
version => '11',
}
class{ 'postgresql::server':
}
postgresql::server::config_entry { 'shared_preload_libraries':
value => 'timescaledb',
}
}
......@@ -12,7 +12,7 @@ Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/bionic64"
config.vm.box = "ubuntu/disco64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment