Skip to content

Commit ad652d4

Browse files
committed
publish
0 parents  commit ad652d4

File tree

13 files changed

+248
-0
lines changed

13 files changed

+248
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.swp

Gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2+
3+
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3']
4+
gem 'metadata-json-lint'
5+
gem 'puppet', puppetversion
6+
gem 'puppetlabs_spec_helper', '>= 1.0.0'
7+
gem 'puppet-lint', '>= 1.0.0'
8+
gem 'facter', '>= 1.7.0'
9+
gem 'rspec-puppet'
10+
11+
# rspec must be v2 for ruby 1.8.7
12+
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
13+
gem 'rspec', '~> 2.0'
14+
gem 'rake', '~> 10.0'
15+
else
16+
# rubocop requires ruby >= 1.9
17+
gem 'rubocop'
18+
end

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cactos_runtime_controller
2+
3+
See `manifests/init.pp` for a short description and a usage example

Rakefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'puppetlabs_spec_helper/rake_tasks'
2+
require 'puppet-lint/tasks/puppet-lint'
3+
require 'metadata-json-lint/rake_task'
4+
5+
if RUBY_VERSION >= '1.9'
6+
require 'rubocop/rake_task'
7+
RuboCop::RakeTask.new
8+
end
9+
10+
PuppetLint.configuration.send('disable_80chars')
11+
PuppetLint.configuration.relative = true
12+
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
13+
14+
desc 'Validate manifests, templates, and ruby files'
15+
task :validate do
16+
Dir['manifests/**/*.pp'].each do |manifest|
17+
sh "puppet parser validate --noop #{manifest}"
18+
end
19+
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
20+
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
21+
end
22+
Dir['templates/**/*.erb'].each do |template|
23+
sh "erb -P -x -T '-' #{template} | ruby -c"
24+
end
25+
end
26+
27+
desc 'Run metadata_lint, lint, validate, and spec tests.'
28+
task :test do
29+
[:metadata_lint, :lint, :validate, :spec].each do |test|
30+
Rake::Task[test].invoke
31+
end
32+
end

examples/init.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The baseline for module testing used by Puppet Labs is that each manifest
2+
# should have a corresponding test manifest that declares that class or defined
3+
# type.
4+
#
5+
# Tests are then run by using puppet apply --noop (to check for compilation
6+
# errors and view a log of events) or by fully applying the test in a virtual
7+
# environment (to compare the resulting system state to the desired state).
8+
#
9+
# Learn more about module testing here:
10+
# https://docs.puppet.com/guides/tests_smoke.html
11+
#
12+
include ::cactos_runtime_controller

manifests/config.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
class cactos_runtime_controller::config inherits cactos_runtime_controller{
3+
4+
5+
file_line { 'opt_options.js':
6+
ensure => present,
7+
path => '/opt/rtc/runtime-controller/src/opt_options.js',
8+
line => "const optConfigDir = \"$optConfigDir\"",
9+
match => '^const\ optConfigDir\ \=',
10+
}
11+
}

manifests/init.pp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Class: cactos_runtime_controller
2+
# ===========================
3+
#
4+
# Installs the cactos runtime controller
5+
#
6+
# Parameters
7+
# ----------
8+
#
9+
# * `optConfigDir`
10+
# Specify the location of cactosfp7 configuration
11+
#
12+
# Examples
13+
# --------
14+
#
15+
# @example
16+
# class { 'cactos_runtime_controller':
17+
# $optConfigDir => '/var/eu.cactosfp7.configuration/',
18+
# }
19+
#
20+
# Authors
21+
# -------
22+
#
23+
# Simon Volpert <[email protected]>
24+
# Frank Griesinger <[email protected]>
25+
#
26+
class cactos_runtime_controller (
27+
28+
$optConfigDir = $cactos_runtime_controller::params::optConfigDir,
29+
30+
)inherits cactos_runtime_controller::params{
31+
32+
contain cactos_runtime_controller::install
33+
contain cactos_runtime_controller::config
34+
contain cactos_runtime_controller::service
35+
Class['::cactos_runtime_controller::install']->
36+
Class['::cactos_runtime_controller::config']->
37+
Class['::cactos_runtime_controller::service']
38+
39+
##TODO change PORT name
40+
## file server.js line "const PORT=8080;"
41+
42+
##TODO change global config
43+
## file global.js line "var config = {..."
44+
45+
##TODO change colosseum config
46+
## file colosseum.js line all
47+
48+
}

manifests/install.pp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
class cactos_runtime_controller::install inherits cactos_runtime_controller{
3+
4+
# install sed
5+
package { 'sed':
6+
ensure => 'installed',
7+
}
8+
9+
# install bash
10+
package { 'bash':
11+
ensure => 'installed',
12+
}
13+
14+
# install git
15+
package { 'git':
16+
ensure => 'installed',
17+
}
18+
19+
# install grep
20+
package { 'grep':
21+
ensure => 'installed',
22+
}
23+
notify{'runtime-controller':}
24+
25+
# install nodejs with epel
26+
class { '::nodejs':
27+
nodejs_dev_package_ensure => 'present',
28+
npm_package_ensure => 'present',
29+
repo_class => '::epel',
30+
}
31+
32+
# create rt controller directory
33+
file { '/opt/rtc/':
34+
ensure => directory,
35+
}
36+
37+
# clone repo
38+
vcsrepo { '/opt/rtc/':
39+
ensure => present,
40+
provider => git,
41+
source => 'https://github.com/cactos/Cactos-Runtime.git',
42+
remote => 'origin',
43+
require => Package['git'],
44+
}
45+
46+
# check for binary
47+
file { '/opt/rtc/runtime-controller/bin/config_operator.sh':
48+
ensure => present,
49+
mode => 755,
50+
}
51+
52+
# install httpdispatcher
53+
nodejs::npm { 'httpdispatcher':
54+
ensure => 'present',
55+
package => 'httpdispatcher',
56+
target => '/opt/rtc/runtime-controller/src',
57+
require => Vcsrepo['/opt/rtc/'],
58+
}
59+
60+
# install shelljs
61+
nodejs::npm { 'shelljs':
62+
ensure => 'present',
63+
package => 'shelljs',
64+
target => '/opt/rtc/runtime-controller/src',
65+
require => Vcsrepo['/opt/rtc/'],
66+
}
67+
68+
}
69+

manifests/params.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# == Class cactos_monitoring_gui::params
2+
#
3+
# This class is meant to be called from cactos_monitoring_gui.
4+
# It sets variables according to platform.
5+
#
6+
class cactos_runtime_controller::params{
7+
8+
$optConfigDir = "/tmp/eu.cactosfp7.configuration/"
9+
10+
}

manifests/service.pp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
class cactos_runtime_controller::service inherits cactos_runtime_controller{
3+
4+
# Run the node js app as service
5+
service { 'rtc':
6+
#require => [
7+
#Nodejs::Npm['shelljs'],
8+
#Nodejs::Npm['httpdispatcher'],
9+
#Package['sed'],
10+
#Package['grep'],
11+
#Package['bash'],
12+
## add config to dependency
13+
#],
14+
ensure => running,
15+
start => "nohup node /opt/rtc/runtime-controller/src/server.js 2>&1 >> /var/log/runtime-controller-nodejs.log &",
16+
stop => "/usr/bin/pkill -f server.js",
17+
pattern => "server.js", #todo improve pattern to avoid ambiguity
18+
provider => 'base',
19+
}
20+
}

metadata.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "cactos-cactos_runtime_controller",
3+
"version": "0.1.0",
4+
"author": "cactos",
5+
"summary": null,
6+
"license": "Apache-2.0",
7+
"source": "",
8+
"project_page": null,
9+
"issues_url": null,
10+
"dependencies": [
11+
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"},
12+
{"name":"puppet-nodejs","version_requirement":">= 2.1.0"},
13+
{"name":"puppetlabs-vcsrepo","version_requirement":">= 1.4.0"}
14+
],
15+
"data_provider": null
16+
}
17+

spec/classes/init_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'spec_helper'
2+
describe 'cactos_runtime_controller' do
3+
context 'with default values for all parameters' do
4+
it { should contain_class('cactos_runtime_controller') }
5+
end
6+
end

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'puppetlabs_spec_helper/module_spec_helper'

0 commit comments

Comments
 (0)