Giter VIP home page Giter VIP logo

sensu-omnibus's Introduction

sensu

Build Status MIT Licensed Join the chat at https://slack.sensu.io/

⚠️ ANNOUNCEMENT - Sensu 1.x has reached End-Of-Life (December 31st, 2019)

The Sensu 1.x project reached end-of-life on December 31st, 2019. The existing package repositories became unreachable on January 6th, 2020. Please see our blog post for more details: https://blog.sensu.io/announcing-the-sensu-archives

Sensu 1.x has been superseded by Sensu Go.

As always, we want to hear from the Community and please reach out on Slack or Discourse if you have any questions or concerns.

Sensu Omnibus project

This project uses Chef's Omnibus toolchain to create full-stack platform-specific Sensu packages.

The configuration data in this repository describes the various dependencies which are built and included in the Sensu omnibus package. In addition to omnibus configuration, the project also includes a Chef cookbook, Test Kitchen and Travis CI configuration for executing individual builds in AWS EC2 compute instances.

Supported Platforms

Packages Built Using Automation Pipeline

Packages for Linux platforms are built automatically whenever a tag following the format $SENSU_VERSION-$BUILD_NUMBER is created on this repository.

This is accomplished using Travis CI to run Test Kitchen for the following platform and architecture combinations:

Platform & Version 64bit 32bit Comments
Ubuntu 12.04
Ubuntu 14.04
Ubuntu 16.04 No official 32bit images
Ubuntu 18.04 No official 32bit images
Debian 7
Debian 8 No official 32bit images
Debian 9 No official 32bit images
CentOS 5 32 and 64bit images built with sensu-omnibus-packer
CentOS 6 Using unofficial 32bit image
CentOS 7 No official 32bit images
FreeBSD 10 Official 32bit images are out of date
FreeBSD 11 No official 32bit images
Windows 2012r2 32bit artifact built on 64bit platform
Mac OS X 10.10 See Mac platform notes for instructions
Mac OS X 10.11 See Mac platform notes for instructions
macOS 10.12 See Mac platform notes for instructions

Packages Built By Hand

Additional platform packages are built by hand on an ad hoc basis. We hope to add these builds to the automation pipeline in the future.

Platform & Version Architecture Comments
AIX PowerPC See AIX platform notes for instructions
Solaris 10 i386 See Solaris 10 for instructions
Solaris 11 i386 Documentation needed

Installation

This project requires a Ruby 1.9+ environment with Bundler installed. Ensure all the required gems are installed:

$ bundle install --binstubs

Test Kitchen Usage

The Test Kitchen .kitchen.yml configuration in this project defines the list of platforms we can build using Test Kitchen + Travis CI automation.

In combination with the sensu_omnibus cookbook and Berksfile included in this project, builds can be initiated on EC2 instances from your local environment using the kitchen command, e.g.:

$ ./bin/kitchen test ubuntu-1204

This test will provision a new EC2 instance, install Chef and use Chef to initiate a Sensu package build using the values of environment variables described in the next section.

For a complete list of all commands and platforms, run kitchen list or kitchen help.

Test Kitchen Environment Variables

Automated builds use a Test Kitchen configuration which relies on the following environment variables set to appropriate values:

Environment Variable Description
AWS_REGION Region where AWS instances will be created
AWS_ACCESS_KEY_ID Access key ID for AWS account
AWS_SECRET_ACCESS_KEY Secret access key for AWS account
AWS_SSH_KEY_ID Name of SSH key pair (must exist in specified AWS region)
AWS_SSH_KEY_PATH Local path to SSH private key matching named SSH key
SENSU_VERSION Must correspond to a published Sensu gem available on RubyGems
BUILD_NUMBER Denotes the incremental build number used for package artifacts

Additionally, the following optional environment variables are used if they are set:

Environment Variable Description
AWS_IAM_PROFILE_NAME Optional IAM profile name to be associated with EC2 instances
BUILD_PLATFORM Optional platform name, set by Travis CI when creating per-platform jobs
TRAVIS_JOB_NUMBER Optional job identifier, set by Travis CI. Used for tagging EC2 instances
GPG_PASSPHRASE Optional passphrase for signing package artifacts; currently unused
GNUPG_PATH Optional path to gpg keyring for signing package artifacts; currently unused
AWS_S3_CACHE_BUCKET S3 bucket containing optional build dependency cache. If unset, dependencies are downloaded directly from upstream sources.
AWS_S3_ARTIFACT_BUCKET S3 bucket where build artifacts (packages) will be uploaded after a successful build.

AWS Credential Security

Automated build pipeline makes use of Travis CI encryption to secure sensitive environment variables, as well as a copy of the ssh private key required to access the EC2 instances this pipeline creates.

As a result, should the AWS credentials or ssh key pair for this pipeline require rotating, the travis utility should be used to:

  • update the secure environment variables in .travis.yml:

travis encrypt AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... --add

  • update the ciphertext copy of ssh private key in .travis/sensu-omnibus-artifact-builder.pem.enc:

    travis encrypt-file sensu-omnibus-artifact-builder.pem

sensu-omnibus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-omnibus's Issues

EventMachine SSL is broken on Windows 0.27 and newer

Under Sensu 0.27 we're seeing an exception from EventMachine when transport ssl attributes are configured:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Encryption not available on this event-machine

Refactor sensu bin stubs to act as wrappers for configuring environment

With systemd, smf and other service management systems we can't depend on being able to conditionally set environment variables (e.g. setting PATH and GEM_PATH based on value of EMBEDDED_RUBY).

As a result, we should investigate consolidating any such logic in refactored sensu bin stubs that can set up the environment properly before starting the process. This should give us consistent behavior across platforms without having to maintain the same behavior across multiple service management systems.

Relates to sensu/sensu-build#108

DISCUSS: Service management on Linux platforms

The Sensu packages currently built with the deprecated sensu-build toolchain installs sysv scripts by default. The package also offers an optional embedded runit supervisor, and provides example service scripts for upstart and systemd.

In this sense, upstart and systemd have been considered "unofficially supported" service supervisors for a while now. Unfortunately this "unofficial" designation has meant that the upstart and systemd scripts have long been subject of issues like the those described in sensu/sensu-build#108, and elsewhere.

With the upcoming 0.27 release of Sensu we will be addressing this problem by removing the embedded runit supervisor, dropping upstart as a supported init, and adding official support for systemd.

TL;DR 0.27 will include the following changes to service management:

  • The embedded runit supervisor will be removed from the Sensu package
  • The unofficially supported upstart scripts will be removed from the Sensu Package
  • If sysv scripts are present, the package will update them to use the new sensu-service binstub
  • If no sysv scripts are present and systemd is the running init, systemd unit files will be installed in /etc/systemd/system
  • We will build individual packages for each supported platform and release version.
  • These per-platform version packages will unconditionally install init scripts or systemd unit files, depending on the init or service management system supported by the platform release version.

This will be a breaking change for some folks, particularly those who currently rely on the embedded runit supervisor.

By now we think it is clear that systemd has become the defacto standard for the Linux distributions we aim to support, and that this change to support sysv and systemd exclusively will be an overall improvement for Sensu operators and administrators.

Remove dependency on omnibus cookbook fork

We're presently dependent on our own fork of the Omnibus cookbook (sensu/omnibus-cookbook) to run our builds via Travis, both on Linux and Windows. The dependency stems from the following:

  • Added live_stream property to omnibus_build resources so we get enough output to allow Travis to finish a build Merged in chef-boneyard/omnibus#193)
  • Added conditions to avoid errors on Windows platforms where the omnibus group cannot be created Merged in chef-boneyard/omnibus#189)

Changes that enable the above are present in the sensu branch of sensu/omnibus-cookbook.

Once the PRs linked above have been merged and released, we should switch to an upstream release of the cookbook. we should rewrite the sensu branch on upstream master.

Yum Upgrade of Sensu RPM Purges Sensu Files

The sensu RPM is purging sensu files during a yum upgrade. After an upgrade of the sensu RPM from sensu-0.27.0-2 to sensu-0.27.0-3 the package is installed but there are no longer /opt/sensu and /var/cache/sensu directories.

I'm seeing this happen on CentOS Linux release 7.3.1611. I'm running Puppet in opt mode on my dev and qa systems which are set to install the latest sensu package. As these systems updated to the sensu-0.27.0-3 package I noticed sensu was no longer running. Digging deeper I see that the /opt/sensu directory is gone. This is happening on dozens of VMs consistently.

I've also manually installed the sensu-0.27.0-2 package then upgraded to sensu-0.27.0-3 using yum commands and see the same behaviour. So I know it is not a problem with puppet managing the package.

I have to do some more debugging but I think it may be a problem with the postuninstall scriptlet. It looks like this part of the script is executed during an upgrade even though it should not.

# only execute this script on rhel-based distros if an rpm uninstall
# is taking place
if [ $1 -eq 0 ]; then
  purge_sensu_services
  purge_sensu_files
fi

During an upgrade the argument passed to the postuninstall scriptlet should be 1 and should not execute the code above but for some reason I think it is getting executed.

I question if the manual purging of sensu files is even necessary since the RPM itself should remove the files if the package is uninstalled.

To work around this issue right now I have to yum erase sensu and then reinstall. I'll keep digging into the root cause and potential fix of the issue.

CentOS / RHEL RPMs do not support epoch

All of our sensu-build RPM releases have epoch=1. Our new build tools do not support the epoch attribute and as a result it defaults to 0. This causes an issue where old builds are actually seen as "newer" as the epoch value takes precedence over the Sensu version.

As a temporary workaround, I think we should implement support for epoch in Omnibus.

As a permanent fix, we should ensure epoch=0 and use a new yum repository free of any epoch=1 RPMs.

Enable kitchen-ec2 builds for build pipeline

We're moving towards building packages in an automated fashion by using kitchen-ec2. We need to ensure that the the following platforms are in a working state:

  • Ubuntu 12.04 (i386, amd64)
  • Ubuntu 14.04 (i386, amd64)
  • Ubuntu 16.04 (i386, amd64)
  • Debian 7 (i386, amd64)
  • Debian 8 (i386, amd64)
  • CentOS/RHEL 5 (i386, amd64) # no 1st party AMIs
  • CentOS/RHEL 6 (i386, amd64)
  • CentOS/RHEL 7 (i386, amd64)
  • FreeBSD 10 (amd64)

DRY up .kitchen.yml

in #58 we add some code to .kitchen.yml for copying GPG keys into the build VM when certain environment variables are set. We should try to reduce duplication in this file by defining helper methods which can be used in each applicable platform definition.

Investigate using Solaris native compiler instead of GCC

Per a friend of mine:

the solaris compiler toolchain outputs like 20x faster binaries [cf. gcc]

As a some-day nice-to-have, we should evaluate the truth of this claim and whether or not we can easily adapt our omnibus builds to use a compiler other than gcc.

Investigate adding .NET dependency to the Windows installer

The Sensu installer on Windows does not currently check for the .NET dependency needed for Sensu. I believe there is a way for the installer to refuse to install unless runtime dependencies exist. We should implement this if it is indeed possible.

Windows builds need CA certificates

Windows builds past and present ship without CA certificates in the location specified by OpenSSL::X509::DEFAULT_CERT_FILE

Proposed fix:
curl https://curl.haxx.se/ca/cacert.pem -o "$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')"

sysvinit scripts are not compliant with LSB, specifically 'start' and 'stop' exit codes

The sysvinit scripts on CentOS/RedHat/Amazon Linux return an error exit code if you try to stop a stopped service or start a running service.

For all other init-script actions, the init script shall return an exit status of zero if the action was successful. Otherwise, the exit status shall be non-zero, as defined below. In addition to straightforward success, the following situations are also to be considered successful:

restarting a service (instead of reloading it) with the force-reload argument

running start on a service already running

running stop on a service already stopped or not running

running restart on a service already stopped or not running

running try-restart on a service already stopped or not running

Still the recommended behaviour -
http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

and dates from LSB 1.0.0 http://refspecs.linuxfoundation.org/LSB_1.0.0/gLSB.html#INISCRPTACT

Please will you make this compliant, since it is causing problems with our production instances.

Centos/RHEL packages are generated with distro tags that createrepo can't deal with

See http://blog.packagecloud.io/eng/2014/10/20/yum-createrepo-generate-incorrect-metadata/ for a detailed writeup.

In our case, omnibus is generating a "distro_tag" like ".el5" which is added to the package name, meaning we get artifacts like sensu-0.26.4-4.el5.x86_64.rpm. The bugs in createrepo generate repo metadata for such packages with an invalid release designation, e.g. 4.el5 instead of 4. Yum fails to download and install these newer packages with an invalid release.

failures in postinst aren't caught and leave package in broken state

In testing upgrades from 0.26.5-2 to 0.27.0.beta.1-3 I've found that failing to create the sensu-install symlink when executing the postinst script causes the package installation to be incomplete.

Via Chef debug log, i see the following

       [2016-11-24T01:35:49+00:00] DEBUG: yum_package[sensu]: yum command: "yum -d0 -e0 -y install sensu-0.27.0.beta.1-3.el5"
       Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
       You're about to install sensu!
       systemd detected, but sysv init scripts are present so we'll use those instead
       Installing sensu-api sysv init script
       Installing sensu-client sysv init script
       Installing sensu-server sysv init script
       Installing sensu-service-init sysv init script
       ln: failed to create symbolic link ‘/usr/bin/sensu-install’: File exists
       Thank you for installing Sensu!
       warning: /etc/default/sensu saved as /etc/default/sensu.rpmsave
       [2016-11-24T01:36:24+00:00] INFO: yum_package[sensu] installed sensu at 0.27.0.beta.1-3.el5

Even though the log indicates that sysv init scripts are being installed, I dont see them in /etc/init.d ?

Windows package should install service without starting it

The Windows MSI includes an XML file defining the service, and in #9 we have commits for adding the -d and -c flags to load configuration. I think it will be more consistent with our other packages if the service definition is installed by the package but not enabled/started automatically.

This repository should be open to the public

Let's start a checklist for any blockers preventing us from opening this repo to the public.

  • Reposition AIX ISO and remove details from README
  • Rename repo to sensu-omnibus for consistency w/ other projects

Remove config.json.example

We should remove the config.json.example file included in packages as we're recommending using the conf.d directory for storing Sensu configuration.

please provide a proper Debian/Ubuntu packages

Packages built this way don't appear to meet any of the requirements for inclusion in the official Debian or Ubuntu repositories.

Can you please prepare a proper package and propose it for inclusion in Debian?

Upgrading to v0.27 from v0.26 removes /etc/init.d/scripts in Debian 8.

Today, after upgrading sensu to v0.27, I could not find the service scripts (sensu-server, sensu-client, sensu-api) in the /etc/init.d/ directory. v0.27 seems to have removed them. Downgrading back to v0.26 brings them back.

# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian

# arch 
x86_64

Use Ruby >= 2.3.3

Wondering if we should ship with Ruby 2.3.1 instead of 2.3.0. 2.3.1 includes many bug fixes and is considered the current stable version.

sensu-install fails in some environments due to rubygems IP address error

As described in sensu/sensu#1474, there appears to be a problem with current releases of rubygems when installing packages in some environments (see rubygems/rubygems#1626).

[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu gem 'sensu-plugins-process-checks' is already installed ...
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-process-checks"]
[SENSU-INSTALL] installing Sensu gem 'sensu-plugins-process-checks'
ERROR:  While executing gem ... (ArgumentError)
    IPv4 address expects 4 bytes but 0 bytes
[SENSU-INSTALL] failed to install Sensu gem 'sensu-plugins-process-checks'
[SENSU-INSTALL] you can run the sensu-install command again with --verbose for more info
[SENSU-INSTALL] please take note of any failure messages above
[SENSU-INSTALL] make sure you have build tools installed (e.g. gcc)
[SENSU-INSTALL] trying to determine the Sensu plugin homepage for sensu-plugins-process-checks ...
ERROR:  While executing gem ... (ArgumentError)
    IPv4 address expects 4 bytes but 0 bytes

Once this issue is fixed upstream we should make sure to update the version of rubygems used in our build.

postinst script should not install systemd unit files if sysv scripts are already present

In #34 we describe a behavior that isn't yet implemented in the postinst script, specifically:

If no sysv scripts are present and systemd is the running init, systemd unit files will be installed in /etc/systemd/system

but we also want to update the sysv scripts if they are present:

If sysv scripts are present, the package will update them to use the new sensu-service binstub

sysv init scripts should pass their PATH to sensu-service binstub

In my testing the PATH environment variable constructed by our sysv init scripts (e.g. /etc/init.d/sensu-server) is not effective when services are started by the sensu-service binstub.

As described in sensu/sensu#1606, this is causing Sensu services to run with an incorrect environment, e.g. HANDLER_DIR is being omitted in the effective PATH when sensu-service starts the sensu-server process.

Artifact build matrix should be documented in readme

We currently use particular platform versions to generate "lowest common denominator" package artifacts, e.g. Building 32bit .deb packages on Debian 7.8 allows them be used on Ubuntu 12.04 and other newer 32bit distributions.

In my mind this means that cutting a new release using omnibus requires us to reference an undocumented build matrix to generate artifacts on the correct platforms, so we should document this matrix.

glibc too new for Debian 7

Installing 0.26.4-5 on Debian 7.11:

root@5b292e3a-bc2c-ccc2-b880-d0fde1408218:~# /etc/init.d/sensu-server start
Starting sensu-server:/opt/sensu/embedded/bin/ruby: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /opt/sensu/embedded/lib/libruby.so.2.3)

Automated Windows Builds

Windows builds via omnibus are currently in a separate git branch and only work on a hand-configured Windows VM.

We want these changes merged to master and the ability to build artifacts by running kitchen converge as we do with other platforms.

Sensu services won't start on Ubuntu 14.04

The sysvinit scripts (such as /etc/init.d/sensu-client), which are generated by https://github.com/sensu/sensu-omnibus/blob/master/config/templates/sensu-gem/sysvinit/sensu-service.erb

call start-stop-daemon thus:

start-stop-daemon --start --chuid sensu --pidfile /var/run/sensu/sensu-client.pid --exec /opt/sensu/bin/sensu-service start client fork

(/etc/init.d/sensu-client line 118 in 0.27)

The problem arises when it tries to create the PID_DIR and PID file in bin/sensu-service, which is this file: https://github.com/sensu/sensu-omnibus/blob/master/files/sensu-gem/bin/sensu-service

bin/sensu-service calls this:

ensure_dir() {
    if [ ! -d $1 ]; then
        mkdir -p $1
        chown -R $2 $1
        chmod 755 $1
    fi
}

On Ubuntu, /var/run (actually /run, to which /var/run is a symlink) is a temp dir on a ram drive, so goes away every boot. It is also owned by root. bin/sensu-service is invoked (by start-stop-daemon) as the sensu user. The sensu user cannot create anything in /var/run (nor chown anything), so it cannot create /var/run/sensu, and startup fails.

Either the init scripts need to create that directory, or sensu-service needs to be invoked as root, and drop privs before starting the sensu services.

Services cannot start after a reboot on RHEL7

On EL7 /var/run is a symlink to a tmpfs mounted on /run, so the contents are automatically cleared every reboot. sensu's systemd units run /opt/sensu/bin/sensu-service as the sensu user. This script attempts to ensure that /var/run/sensu and /var/log/sensu exist, but the sensu user cannot create directories under /run or /var/log. sensu services then fail to start because they cannot write a pid file.

{"timestamp":"2017-01-31T15:50:12.209662-0500","level":"fatal","message":"could not write to pid file","pid_file":"/var/run/sensu/sensu-client.pid"}

The systemd way to handle this is to install a systemd-tmpfiles configuration file and have the directories automatically created; e.g. putting d /run/sensu 0755 sensu sensu - in /etc/tmpfiles.d/sensu.conf.

FreeBSD support

FreeBSD is the only remaining platform that is still using https://github.com/sensu/sensu-build. This project successfully builds on FreeBSD 10.x but Omnibus does not support the pkgng packager. I am currently in the process of adding pkgng support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.