Skip to content

Instantly share code, notes, and snippets.

@joemiller
Created March 28, 2012 15:51
Show Gist options
  • Save joemiller/2227581 to your computer and use it in GitHub Desktop.
Save joemiller/2227581 to your computer and use it in GitHub Desktop.
Sensu "New Pacakging" experiments
#!/bin/sh
pkg_name="sensu"
sensu_ver="0.9.4"
sensu_home="/opt/sensu"
iteration="1"
## install fpm and rpmbuild ##
echo "==> Installing dependencies.."
gem install fpm --no-rdoc --no-ri
yum -y install rpm-build
## install sensu and all dependencies to $sensu_home ##
echo "==> Installing sensu gem and dependencies into '${sensu_home}'.."
gem install --no-ri --no-rdoc \
--install-dir ${sensu_home}/lib \
--bindir ${sensu_home}/bin \
sensu
## setup a skeleton for testing ##
mkdir -p /etc/sensu/conf.d
mkdir -p /etc/sensu/plugins
mkdir -p /etc/sensu/handlers
mkdir -p /var/log/sensu
echo 1 > /etc/sensu/config.json
echo 1 > /etc/sensu/conf.d/rabbitmq.json
echo 1 > /etc/sensu/plugins/check_test
echo 1 > /etc/sensu/handlers/check_test
echo 1 > /etc/logrotate.d/sensu
## package it all up ##
echo "==> Calling fpm to build '${pkg_name}' package.."
fpm -s dir -t rpm -a `uname -m` -n ${pkg_name} -v ${sensu_ver} --iteration ${iteration} \
--config-files /etc/sensu/config.json \
--config-files /etc/sensu/conf.d/rabbitmq.json \
${sensu_home} \
/etc/sensu/handlers/ \
/etc/sensu/plugins/ \
/etc/logrotate.d/sensu \
/var/log/sensu
# TODO: figure out why config-files are being ignored (fpm 0.4.3 bug, #183)
# TODO: pre/post scripts
# TODO: various metadata: url, description, etc
# TODO: init scripts, configs, logrotate
# TODO: support building an rpm via `git + gem build` instead
# of fetching latest from rubygems.org
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "centos-57-x86-64"
# config.vm.box_url = "http://domain.com/path/to/above.box" # TODO..
# config.vm.boot_mode = :gui
config.vm.provision :shell do |shell|
shell.path = "sensu-rpm-build.sh"
# shell.args = "1.5.0"
end
@joemiller
Copy link
Author

if you want to experiment with this, put these files into a dir and run vagrant up then vagrant ssh into the vm and there should be a sensu rpm in ~vagrant

@joemiller
Copy link
Author

Here is an example of the contents of the resulting rpm. Size is: ~ 4.5 MB

/etc/logrotate.d/sensu
/etc/sensu/handlers/check_test
/etc/sensu/plugins/check_test
/opt/sensu/bin/bundle
/opt/sensu/bin/rackup
/opt/sensu/bin/ruby-redis
/opt/sensu/bin/rubygems-cabin-test
/opt/sensu/bin/sensu-api
/opt/sensu/bin/sensu-client
/opt/sensu/bin/sensu-server
/opt/sensu/bin/thin
/opt/sensu/bin/tilt
/opt/sensu/lib/ ..... (a ton of stuff here, obviously =)

@joemiller
Copy link
Author

continuing the work on this here: https://github.com/joemiller/sensu-pkg
might stay in this new repo or merge with @phobos182's sensu-jenkins.git repo in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment