Skip to content

Commit 50e1ce1

Browse files
committed
initial commit
0 parents  commit 50e1ce1

29 files changed

+812
-0
lines changed

.fixtures.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fixtures:
2+
repositories:
3+
forge_modules:
4+
stdlib:
5+
repo: "puppetlabs/stdlib"
6+
ref: "3.2.0"
7+
systemd:
8+
repo: "camptocamp/systemd"
9+
ref: "0.1.1"
10+
symlinks:
11+
lita: "#{source_dir}"

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.*.sw?
2+
pkg/
3+
Gemfile.lock
4+
.vendor/
5+
vendor/
6+
spec/fixtures/
7+
.vagrant/
8+
.bundle/
9+
coverage/
10+
log/

.sync.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
.travis.yml:
3+
hc_secure: "aWQzE9dBdTs2zGrCq8q13FYrB9KuNtJQ0VlWcJVOEf+6qhwWPMu5aKwYKZQcrIswFxGHytIjPuvNf8AAHzfXvtFHPWSURnrRDISlXiCha+B4Opf3BhDFEzK2H7c5JMXhyzYxZJ8iKzBMWipr9UGWm+VsoWLSKsan4qlLcb+V2Gc="
4+

.travis.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
language: ruby
2+
bundler_args: --without development
3+
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
4+
rvm:
5+
- 1.8.7
6+
- 1.9.3
7+
- 2.0.0
8+
- 2.1.0
9+
script:
10+
- "rake lint"
11+
- "rake spec SPEC_OPTS='--format documentation'"
12+
- "rake syntax"
13+
env:
14+
- PUPPET_VERSION="~> 2.7.0"
15+
- PUPPET_VERSION="~> 3.1.0"
16+
- PUPPET_VERSION="~> 3.2.0"
17+
- PUPPET_VERSION="~> 3.3.0"
18+
- PUPPET_VERSION="~> 3.4.0"
19+
- PUPPET_VERSION="~> 3.5.0"
20+
- PUPPET_VERSION="~> 3.6.0"
21+
matrix:
22+
exclude:
23+
- rvm: 1.9.3
24+
env: PUPPET_VERSION="~> 2.7.0"
25+
- rvm: 2.0.0
26+
env: PUPPET_VERSION="~> 2.7.0"
27+
- rvm: 2.0.0
28+
env: PUPPET_VERSION="~> 3.1.0"
29+
- rvm: 2.1.0
30+
env: PUPPET_VERSION="~> 2.7.0"
31+
- rvm: 2.1.0
32+
env: PUPPET_VERSION="~> 3.0.0"
33+
- rvm: 2.1.0
34+
env: PUPPET_VERSION="~> 3.1.0"
35+
- rvm: 2.1.0
36+
env: PUPPET_VERSION="~> 3.2.0"
37+
- rvm: 2.1.0
38+
env: PUPPET_VERSION="~> 3.3.0"
39+
- rvm: 2.1.0
40+
env: PUPPET_VERSION="~> 3.4.0"
41+
notifications:
42+
email: false
43+
hipchat:
44+
rooms:
45+
- secure: "dpF/KF4dTsYh2tkBpxCg5jCYSie+ge+IsUAcwiCfqdVGOqFs8LyaJvHzObVA\naF6up/OFLjRtt979ht9dgUZUHEvbZk0iQpbojSRng8CWJUNobXVE1cLh1HKg\nkTh9NlUu1hu0Eyk139OMZo1bC4nmN83yCBnclymgWnNaT43FttA="
46+
on_success: always
47+
on_failure: always

Gemfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
2+
3+
group :unit_tests do
4+
gem 'rake', :require => false
5+
gem 'rspec', '~> 3.1.0', :require => false
6+
gem 'rspec-puppet', :require => false
7+
gem 'puppetlabs_spec_helper', :require => false
8+
gem 'puppet-lint', '1.0.1', :require => false
9+
gem 'puppet-syntax', :require => false
10+
gem 'metadata-json-lint', :require => false
11+
gem 'json', :require => false
12+
gem 'puppet-lint-absolute_classname-check', :require => false
13+
gem 'puppet-lint-appends-check', :require => false
14+
gem 'puppet-lint-empty_string-check', :require => false
15+
gem 'puppet-lint-file_ensure-check', :require => false
16+
gem 'puppet-lint-leading_zero-check', :require => false
17+
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
18+
gem 'puppet-lint-trailing_comma-check', :require => false
19+
gem 'puppet-lint-undef_in_function-check', :require => false
20+
gem 'puppet-lint-unquoted_string-check', :require => false
21+
gem 'puppet-lint-version_comparison-check', :require => false
22+
end
23+
group :development do
24+
gem 'simplecov', :require => false
25+
gem 'guard-rake', :require => false
26+
end
27+
group :system_tests do
28+
gem 'vagrant-wrapper', :require => false
29+
gem 'beaker-rspec', :require => false
30+
gem 'serverspec', :require => false
31+
end
32+
33+
if facterversion = ENV['FACTER_GEM_VERSION']
34+
gem 'facter', facterversion, :require => false
35+
else
36+
gem 'facter', :require => false
37+
end
38+
39+
if puppetversion = ENV['PUPPET_GEM_VERSION']
40+
gem 'puppet', puppetversion, :require => false
41+
else
42+
gem 'puppet', :require => false
43+
end
44+

LICENSE

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2013 EvenUp Inc
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#modulename
2+
3+
####Table of Contents
4+
5+
1. [Overview](#overview)
6+
2. [Module Description - What the module does and why it is useful](#module-description)
7+
3. [Setup - The basics of getting started with [Modulename]](#setup)
8+
* [What [Modulename] affects](#what-[modulename]-affects)
9+
* [Setup requirements](#setup-requirements)
10+
* [Beginning with [Modulename]](#beginning-with-[Modulename])
11+
4. [Usage - Configuration options and additional functionality](#usage)
12+
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
13+
5. [Limitations - OS compatibility, etc.](#limitations)
14+
6. [Development - Guide for contributing to the module](#development)
15+
16+
##Overview
17+
18+
A one-maybe-two sentence summary of what the module does/what problem it solves. This is your 30 second elevator pitch for your module. Consider including OS/Puppet version it works with.
19+
20+
##Module Description
21+
22+
If applicable, this section should have a brief description of the technology the module integrates with and what that integration enables. This section should answer the questions: "What does this module *do*?" and "Why would I use it?"
23+
24+
If your module has a range of functionality (installation, configuration, management, etc.) this is the time to mention it.
25+
26+
##Setup
27+
28+
###What [Modulename] affects
29+
30+
* A list of files, packages, services, or operations that the module will alter, impact, or execute on the system it's installed on.
31+
* This is a great place to stick any warnings.
32+
* Can be in list or paragraph form.
33+
34+
###Setup Requirements **OPTIONAL**
35+
36+
If your module requires anything extra before setting up (pluginsync enabled, etc.), mention it here.
37+
38+
###Beginning with [Modulename]
39+
40+
The very basic steps needed for a user to get the module up and running.
41+
42+
If your most recent release breaks compatibility or requires particular steps for upgrading, you may wish to include an additional section here: Upgrading (For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
43+
44+
##Usage
45+
46+
Put the classes, types, and resources for customizing, configuring, and doing the fancy stuff with your module here.
47+
48+
##Reference
49+
50+
Here, list the classes, types, providers, facts, etc contained in your module. This section should include all of the under-the-hood workings of your module so people know what the module is touching on their system but don't need to mess with things. (We are working on automating this section!)
51+
52+
##Limitations
53+
54+
This is where you list OS compatibility, version compatibility, etc.
55+
56+
##Development
57+
58+
Since your module is awesome, other users will want to play with it. Let them know what the ground rules for contributing are.
59+
60+
##Release Notes/Contributors/Etc **Optional**
61+
62+
If you aren't using changelog, put your release notes here (though you should consider using changelog). You may also add any additional sections you feel are necessary or important to include here. Please use the `## ` header.

Rakefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'rubygems' if RUBY_VERSION < '1.9.0'
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
require 'puppet-lint/tasks/puppet-lint'
4+
require 'puppet-syntax/tasks/puppet-syntax'
5+
6+
begin
7+
require 'puppet_blacksmith/rake_tasks'
8+
rescue LoadError
9+
end
10+
11+
exclude_paths = [
12+
"pkg/**/*",
13+
"vendor/**/*",
14+
"spec/**/*",
15+
]
16+
17+
PuppetLint.configuration.relative = true
18+
PuppetLint.configuration.fail_on_warnings
19+
PuppetLint.configuration.ignore_paths = exclude_paths
20+
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
21+
PuppetLint.configuration.send('relative')
22+
PuppetLint.configuration.send('disable_80chars')
23+
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
24+
PuppetSyntax.exclude_paths = exclude_paths
25+
26+
desc "Run acceptance tests"
27+
RSpec::Core::RakeTask.new(:acceptance) do |t|
28+
t.pattern = 'spec/acceptance'
29+
end
30+
31+
task :metadata do
32+
sh "metadata-json-lint metadata.json"
33+
end
34+
35+
desc "Run syntax, lint, and spec tests."
36+
task :test => [
37+
:syntax,
38+
:lint,
39+
:metadata,
40+
:spec,
41+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# stringify_symbol.rb
3+
#
4+
5+
module Puppet::Parser::Functions
6+
newfunction(:stringify_symbol, :type => :rvalue, :doc => <<-EOS
7+
This outputs ruby argumentsects attempting to maintain their format to be read in from
8+
a ruby configuration file
9+
EOS
10+
) do |arguments|
11+
12+
if arguments.length != 1
13+
return arguments
14+
end
15+
16+
if arguments[0].is_a?(Symbol)
17+
arguments[0].to_s
18+
elsif arguments[0][0] == ':'
19+
arguments[0][1..-1]
20+
else
21+
arguments[0]
22+
end
23+
24+
end
25+
end
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# typecast.rb
3+
#
4+
5+
module Puppet::Parser::Functions
6+
newfunction(:typecast, :type => :rvalue, :doc => <<-EOS
7+
This outputs ruby argumentsects attempting to maintain their format to be read in from
8+
a ruby configuration file
9+
EOS
10+
) do |arguments|
11+
12+
if arguments.length != 1
13+
return arguments
14+
end
15+
16+
if arguments[0].is_a?(Hash) || arguments[0].is_a?(Array)
17+
# hashes and arrays will be inspected to display properly
18+
arguments[0].inspect
19+
elsif arguments[0].is_a?(Symbol)
20+
# symbols should remain symbols
21+
":#{arguments[0]}"
22+
elsif arguments[0].is_a?(Fixnum) || arguments[0].is_a?(Float) || arguments[0].is_a?(TrueClass) || arguments[0].is_a?(FalseClass)
23+
arguments[0]
24+
else
25+
# must be a string so let's try to convert to a ruby type
26+
case arguments[0]
27+
when /^:/, /^[\{\[]/
28+
# found symbol, array, hash, bool, float, or fixnum
29+
arguments[0]
30+
when /^true$|^false$/
31+
# found boolean
32+
arguments[0] == 'true'
33+
when /^[0-9]+\.[0-9]+$/
34+
# found float
35+
arguments[0].to_f
36+
when /^[0-9]+/
37+
# found Fixnum
38+
arguments[0].to_i
39+
else
40+
# leave it as a string
41+
"\"#{arguments[0]}\""
42+
end
43+
end
44+
45+
end
46+
end

manifests/bot.pp

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
define lita::bot (
2+
$version = $::lita::version,
3+
$adapter = $::lita::adapter,
4+
$bot_name = $::lita::name,
5+
$gems = $::lita::gems,
6+
$mention_name = $::lita::mention_name,
7+
$plugins = $::lita::plugins,
8+
$plugin_config = $::lita::plugin_config,
9+
$admins = $::lita::admins,
10+
$adapter = $::lita::adapter,
11+
$locale = $::lita::locale,
12+
$log_level = $::lita::log_level,
13+
$adapter_config = $::lita::adapter_config,
14+
$http_host = $::lita::http_host,
15+
$http_port = $::lita::http_port,
16+
$redis_host = $::lita::redis_host,
17+
$redis_port = $::lita::redis_port,
18+
) {
19+
20+
if !defined(Class['lita']) {
21+
fail('You must include the lita base class before configuring a bot')
22+
}
23+
24+
$_name = regsubst($name, '[\.\s&]', '_', 'G')
25+
$bot_dir = "${::lita::base_path}/${_name}"
26+
27+
file { $bot_dir:
28+
ensure => 'directory',
29+
owner => 'lita',
30+
group => 'lita',
31+
}
32+
33+
file { "${bot_dir}/Gemfile":
34+
owner => 'lita',
35+
group => 'lita',
36+
content => template('lita/Gemfile.erb'),
37+
notify => Exec["bundle_install_${_name}"],
38+
}
39+
40+
file { "${bot_dir}/lita_config.rb":
41+
owner => 'lita',
42+
group => 'lita',
43+
content => template('lita/lita_config.rb.erb'),
44+
notify => Service["lita_${_name}"],
45+
}
46+
47+
exec { "bundle_install_${_name}":
48+
command => "${::lita::bundler_binpath}/bundle install --path vendor/bundle",
49+
cwd => $bot_dir,
50+
user => 'lita',
51+
refreshonly => true,
52+
notify => Service["lita_${_name}"],
53+
}
54+
55+
file { "/usr/lib/systemd/system/lita@${_name}.service.d":
56+
ensure => 'directory',
57+
}
58+
59+
file { "/usr/lib/systemd/system/lita@${_name}.service.d/workingdir.conf":
60+
ensure => file,
61+
owner => root,
62+
group => root,
63+
mode => '0444',
64+
content => "[Service]\nWorkingDirectory=${bot_dir}\n",
65+
}
66+
67+
file { "/etc/sysconfig/lita-${_name}":
68+
ensure => file,
69+
content => "HOME=${bot_dir}\n",
70+
}
71+
72+
service { "lita_${_name}":
73+
ensure => running,
74+
name => "lita@${_name}",
75+
enable => true,
76+
}
77+
78+
}

0 commit comments

Comments
 (0)