Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated hubot initialization #33

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
94634c3
Updated install.pp
frozenfoxx May 20, 2016
21251c2
Updated config.pp
frozenfoxx May 20, 2016
4ff6cf1
Updated hubot_spec
frozenfoxx May 20, 2016
7f11a7c
Updated travis.yml
frozenfoxx May 23, 2016
af93431
Update config.pp
frozenfoxx May 24, 2016
591a869
Update package.json.erb
frozenfoxx May 24, 2016
78d308c
Added $hubotversion to config.pp
frozenfoxx May 24, 2016
316e429
Update config.pp
frozenfoxx May 24, 2016
12051fd
Update package.json.erb
frozenfoxx May 24, 2016
19b5ed7
Typo in bin directory location
frozenfoxx May 24, 2016
ba82184
Added bin directory creation
frozenfoxx May 25, 2016
af7edcd
Updated directory creation and yeoman building
frozenfoxx May 25, 2016
88baf9c
Update config.pp
frozenfoxx May 25, 2016
3201a59
Update config.pp
frozenfoxx May 25, 2016
0f1386c
Added --no-insight
frozenfoxx May 25, 2016
0fa2b09
Removed directory test
frozenfoxx May 25, 2016
4616214
Update hubot_spec.rb
frozenfoxx May 26, 2016
d125da4
Create hubot.upstart.erb
frozenfoxx Jun 6, 2016
4cf6785
Added Upstart config
frozenfoxx Jun 6, 2016
2bdb5e9
Updated hubot init
frozenfoxx Jun 6, 2016
8e36d2e
Update metadata.json
frozenfoxx Nov 3, 2016
2795505
Update LICENSE
frozenfoxx Nov 3, 2016
d8b8455
Update README.md
frozenfoxx Nov 3, 2016
76b2d19
Delete hubot.init.Debian.erb
frozenfoxx Nov 3, 2016
b0537c9
Create hubot.init.Debian.erb
frozenfoxx Nov 3, 2016
b53f6b7
[hubot_systemd]
Apr 8, 2017
e0a2385
Merge pull request #1 from khdevel/hubot_systemd
frozenfoxx Apr 10, 2017
28bfa82
Updated metadata
frozenfoxx Apr 10, 2017
6116a8e
Run the service as the service account
genebean May 8, 2017
8398f17
Merge pull request #2 from genebean/patch-1
frozenfoxx May 15, 2017
e5ec57d
Updated metadata.json
frozenfoxx May 15, 2017
b5cccee
setting the service provider for hubot service
Nov 15, 2017
bccf78d
Ability to hide diff of hubot environments file template. Also defau…
TraGicCode Nov 30, 2017
5aaf76f
Fixed false
TraGicCode Dec 1, 2017
137c8cf
Merge pull request #6 from TraGicCode/feature/hide-sensitive-environm…
frozenfoxx Dec 6, 2017
c95130c
Updated metadata
frozenfoxx Dec 6, 2017
9d0a8db
systemd for Jessie and higher, otherwise upstart
Dec 22, 2017
76a1397
Updated init_style for Ubuntu and Debian
frozenfoxx Dec 24, 2017
0792d50
Merge pull request #3 from CYPI/master
frozenfoxx Dec 24, 2017
3d707d6
Bumped version
frozenfoxx Dec 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ sudo: false
matrix:
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.0
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 4.0"
allow_failures:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
notifications:
email: false
Expand Down
12 changes: 0 additions & 12 deletions CHANGELOG

This file was deleted.

2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Copyright 2013 EvenUp Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A puppet module that installs and manages a [hubot](http://hubot.github.com) bot

There are two methods of configuring hubot, setting the available parameters (useful for trying it out/simple configs) and storing your config and scripts in git. Instructions below as well on migrating from parameter config to repo configuration.

Configuring via puppet
Configuring via Puppet
----------------------

This method is great for giving hubot a try to figure out what it's all about and maintaining a simple configuration. If you want to be able to run hubot with only the shell adapter, no configuration is required other than including this class and then running /opt/hubot/hubot/bin/hubot (that's a lot of hubots) and interact with him on the shell.
Expand Down Expand Up @@ -69,7 +69,7 @@ Puppet will now keep hubot up to date based on this git repo and restart the ser

Known Issues:
-------------
Only tested on CentOS 6, but should be pretty agnostic. Feedback/PRs appreciated!
Only tested on Ubuntu 14.04 but should be flexible. Feedback/PRs appreciated!


License:
Expand Down
87 changes: 63 additions & 24 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# === Authors
#
# * Foxx Block <mailto:[email protected]>
# * Justin Lambert <mailto:[email protected]>
#
#
Expand All @@ -19,17 +20,47 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

$exports = $::hubot::env_export
$scripts = $::hubot::scripts
$dependencies = $::hubot::dependencies
$exports = $::hubot::env_export
$external_scripts = $::hubot::external_scripts
$dependencies = $::hubot::dependencies
file { '/etc/init.d/hubot':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0555',
content => template("hubot/${hubot::params::hubot_init}"),
notify => Class['hubot::service'],
$hubotversion = $::hubot::hubot_version
$scripts = $::hubot::scripts

case $hubot::init_style {
'upstart': {
file { '/etc/init.d/hubot':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0555',
content => template("hubot/${hubot::params::hubot_init}"),
notify => Class['hubot::service'],
}
file { 'hubot upstart':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0644',
path => '/etc/init/hubot.conf',
content => template('hubot/hubot.upstart.erb'),
}
}
'systemd': {
file { '/lib/systemd/system/hubot.service':
mode => '0644',
owner => 'root',
group => 'root',
content => template('hubot/hubot.systemd.erb'),
}
~> exec { 'hubot-systemd-reload':
command => 'systemctl daemon-reload',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
refreshonly => true,
}
}
default: {
fail("init_style was not specified: ${hubot::init_style}!")
}
}

if $::hubot::git_source {
Expand Down Expand Up @@ -76,28 +107,38 @@
revision => 'master',
notify => Class['hubot::service'],
}

unless empty($::hubot::env_export) {
file { "${::hubot::root_dir}/${::hubot::bot_name}/hubot.env":
ensure => 'file',
owner => 'hubot',
group => 'hubot',
mode => '0440',
content => template('hubot/hubot.env.erb'),
notify => Class['hubot::service'],
require => Vcsrepo["${::hubot::root_dir}/${::hubot::bot_name}"],
ensure => 'file',
owner => 'hubot',
group => 'hubot',
mode => '0440',
show_diff => $::hubot::env_file_show_diff,
content => template('hubot/hubot.env.erb'),
notify => Class['hubot::service'],
require => Vcsrepo["${::hubot::root_dir}/${::hubot::bot_name}"],
}
}

} else {
file { "${::hubot::root_dir}/${::hubot::bot_name}":
ensure => 'directory',
owner => 'hubot',
group => 'hubot',
mode => '0750',
require => File[$::hubot::root_dir],
}

exec { 'Hubot init':
command => "hubot -c ${::hubot::bot_name}",
cwd => $::hubot::root_dir,
path => '/usr/bin',
unless => "test -d ${::hubot::root_dir}/${::hubot::bot_name}",
command => 'yo hubot --defaults --no-insight',
cwd => "${::hubot::root_dir}/${::hubot::bot_name}/",
creates => "${::hubot::root_dir}/${::hubot::bot_name}/bin/hubot",
path => '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
user => 'hubot',
group => 'hubot',
logoutput => 'on_failure',
require => File["${::hubot::root_dir}/${::hubot::bot_name}"],
}

file { "${::hubot::root_dir}/${::hubot::bot_name}/debug.sh":
Expand Down Expand Up @@ -148,7 +189,5 @@
notify => Class['hubot::service'],
require => Exec['Hubot init'],
}

}

}
29 changes: 26 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
# that should be exported for this bot
# Default: {}
#
# [*env_file_show_diff*]
# Boolean. Enable showing diff of hubot environment variable file. Setting this to true could expose
# secrets that might be getting assigned to environment variables for hubot.
# Default: false
#
# [*scripts*]
# Array of Strings. Used when not using git_source. List of scripts to be
# included from hubot-scripts
Expand Down Expand Up @@ -120,6 +125,7 @@
$chat_alias = $::hubot::params::chat_alias,
$build_deps = $::hubot::params::build_deps,
$env_export = $::hubot::params::env_export,
$env_file_show_diff = $::hubot::params::env_file_show_diff,
$scripts = $::hubot::params::scripts,
$external_scripts = $::hubot::params::external_scripts,
$log_file = $::hubot::params::log_file,
Expand All @@ -133,6 +139,8 @@
$service_enable = $::hubot::params::service_enable,
$install_nodejs = $::hubot::params::install_nodejs,
$nodejs_manage_repo = $::hubot::params::nodejs_manage_repo,
$init_style = $::hubot::params::init_style,

) inherits hubot::params {

if $log_file {
Expand All @@ -150,10 +158,25 @@
}

if $install_nodejs {
class { '::nodejs':
manage_package_repo => $nodejs_manage_repo,
before => Package['hubot'],

case $init_style {
'upstart': {
class { '::nodejs':
manage_package_repo => $nodejs_manage_repo,
before => Package['hubot'],
}
}
'systemd': {
class { '::nodejs':
manage_package_repo => $nodejs_manage_repo,
nodejs_dev_package_ensure => 'present',
npm_package_ensure => 'present',
before => Package['hubot'],
}
}
default: {}
}

}

class { '::hubot::install': }
Expand Down
12 changes: 12 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@
require => Package['hubot'],
provider => 'npm'
})

ensure_resource('package', 'generator-hubot', {
ensure => present,
require => Package['hubot'],
provider => 'npm'
})

ensure_resource('package', 'yo', {
ensure => present,
require => Package['hubot'],
provider => 'npm'
})
}
25 changes: 24 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$chat_alias = '/'
$build_deps = []
$env_export = {}
$env_file_show_diff = false
$scripts = []
$external_scripts = []
$log_file = undef
Expand All @@ -35,10 +36,32 @@
$install_nodejs = true

case $::operatingsystem {
/Ubuntu|Debian/: {
/Debian/: {
if versioncmp($::operatingsystemrelease, '7.0') > 0 {
$init_style = 'systemd'
}
else {
$init_style = 'debian'
}
$hubot_init = "hubot.init.${::operatingsystem}.erb"
$nodejs_manage_repo = true
}
/Ubuntu/: {
if versioncmp($::operatingsystemrelease, '14.04') > 0 {
$init_style = 'systemd'
}
else {
$init_style = 'upstart'
}
$hubot_init = "hubot.init.${::operatingsystem}.erb"
$nodejs_manage_repo = true
}
/RedHat|CentOS/: {
if versioncmp($::operatingsystemrelease, '7.0') > 0 {
$init_style = 'systemd'
$nodejs_manage_repo = false
}
}
default: {
$hubot_init = 'hubot.init.erb'
$nodejs_manage_repo = false
Expand Down
18 changes: 9 additions & 9 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "evenup-hubot",
"version": "0.2.0",
"author": "Justin Lambert <jlambert@letsevenup.com>",
"name": "frozenfoxx-hubot",
"version": "1.4.0",
"author": "frozenfoxx <siliconfoxx@gmail.com>",
"license": "Apache-2.0",
"summary": "Installs, configures, and runs a hubot bot by configuring all parameters or as config from a git repo",
"source": "https://github.com/evenup/evenup-hubot",
"project_page": "https://github.com/evenup/evenup-hubot",
"issues_url": "https://github.com/evenup/evenup-hubot/issues",
"tags": ["hubot", "jira"],
"source": "https://github.com/frozenfoxx/puppet-hubot",
"project_page": "https://github.com/frozenfoxx/puppet-hubot",
"issues_url": "https://github.com/frozenfoxx/puppet-hubot/issues",
"tags": ["hubot", "chatops"],
"operatingsystem_support": [
{ "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] },
{ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04" ] },
{ "operatingsystem": "Debian", "operatingsystemrelease": [ "7", "8" ] }
],
"dependencies": [
{ "name": "puppet/nodejs", "version_requirement": ">=1.0.0 <2.0.0" },
{ "name": "puppet/nodejs", "version_requirement": ">=1.0.0 <2.3.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">=3.2.0 <5.0.0" }
]
}
9 changes: 4 additions & 5 deletions spec/classes/hubot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@

context 'no git_source' do
it { should contain_exec('Hubot init').with(
:command => 'hubot -c hubot',
:cwd => '/opt/hubot',
:unless => 'test -d /opt/hubot/hubot'
:command => 'yo hubot --defaults --no-insight',
:cwd => '/opt/hubot/hubot',
) }
it { should contain_file('/opt/hubot/hubot/hubot.env')}
it { should contain_file('/opt/hubot/hubot/hubot-scripts.json')}
Expand All @@ -120,8 +119,8 @@
context 'changing bot_name' do
let(:params) { { :bot_name => 'foobot' } }
it { should contain_exec('Hubot init').with(
:command => 'hubot -c foobot',
:unless => 'test -d /opt/hubot/foobot'
:command => 'yo hubot --defaults --no-insight',
:cwd => '/opt/hubot/foobot',
) }
it { should contain_file('/opt/hubot/foobot/hubot.env')}
it { should contain_file('/opt/hubot/foobot/hubot-scripts.json')}
Expand Down
4 changes: 4 additions & 0 deletions templates/hubot.env.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<% @exports.sort_by{|k,v| k}.each do |k,v| -%>
<% if scope.lookupvar('hubot::init_style') == 'upstart' -%>
export <%= "#{k}=\"#{v}\"" %>
<% elsif scope.lookupvar('hubot::init_style') == 'systemd' -%>
<%= "#{k}=\"#{v}\"" %>
<% end -%>
<% end -%>
1 change: 0 additions & 1 deletion templates/hubot.init.Debian.erb

This file was deleted.

Loading