Skip to content

Commit

Permalink
Add support for web installations
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Vanlancker <carroarmato0@inuits.eu>
  • Loading branch information
carroarmato0 committed Nov 11, 2017
1 parent 248fad4 commit 844eb16
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 107 deletions.
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -24,11 +24,19 @@ This module relies on hiera in order to manage the common settings in the skydiv

* hiera
* [concat](https://github.com/puppetlabs/puppetlabs-concat) <= 2.2.1
* [stdlib](https://github.com/puppetlabs/puppetlabs-stdlib) <= 4.7.1
* [archive](https://github.com/voxpupuli/puppet-archive.git) <= 1.2.0

### What skydive affects

The module offers a class to install and manage the Skydive Analyzer and Agent separately.

Depending on the configuration, it may affect:

* Management of the Yum Repository
* Management of the skydive binary
* Skydive RPM packages

### Beginning with skydive

## Usage
Expand Down Expand Up @@ -79,6 +87,24 @@ Change default address and port of the analyzer's UI. (don't forget to correct t
skydive::analyzer::listen: 0.0.0.0:80
```

Specify a specific version through Web installation

```
---
skydive::installation_type: web
skydive::version: 0.12.0
skydive::web_checksum: '66959586f0865e39f9a66cf30f2b87de5b10921a'
```

Specify a Package installation

```
---
skydive::installation_type: package
skydive::version: present
```


## Limitations

The module has been tested on:
Expand Down
1 change: 1 addition & 0 deletions manifests/agent.pp
Expand Up @@ -9,6 +9,7 @@
$extra_config = {},
) inherits ::skydive {

contain ::skydive
contain ::skydive::install::agent
contain ::skydive::config::agent
contain ::skydive::service::agent
Expand Down
37 changes: 25 additions & 12 deletions manifests/init.pp
@@ -1,19 +1,32 @@
# class skydive
class skydive (
$manage_repo = $::skydive::params::manage_repo,
$host_id = $::skydive::params::host_id,
$logging = $::skydive::params::logging,
$graph = $::skydive::params::graph,
$cache = $::skydive::params::cache,
$analyzers = $::skydive::params::analyzers,
$etcd = $::skydive::params::etcd,
$ws_pong_timeout = $::skydive::params::ws_pong_timeout,
$ws_bulk_maxmsg = $::skydive::params::ws_bulk_maxmsg,
$ws_bulk_maxdelay = $::skydive::params::ws_bulk_maxdelay,
$extra_config = {},
$host_id = $::skydive::params::host_id,
$logging = $::skydive::params::logging,
$graph = $::skydive::params::graph,
$cache = $::skydive::params::cache,
$analyzers = $::skydive::params::analyzers,
$etcd = $::skydive::params::etcd,
$version = $::skydive::params::version,
$web_checksum = $::skydive::params::web_checksum,
$manage_repo = $::skydive::params::manage_repo,
$installation_type = $::skydive::params::installation_type,
$ws_pong_timeout = $::skydive::params::ws_pong_timeout,
$ws_bulk_maxmsg = $::skydive::params::ws_bulk_maxmsg,
$ws_bulk_maxdelay = $::skydive::params::ws_bulk_maxdelay,
$extra_config = {},
) inherits ::skydive::params {

contain ::skydive::install::common
# Some validations
## Validate allowed installation_type
if ! ($installation_type in [ 'web', 'package' ]) {
fail("Installation type: ${installation_type} invalid. Allowed installation types are: web, package")
}
# When doing a web install, the version must be specified, 'present' is not valid
if $installation_type == 'web' and $version in ['present', 'latest'] {
fail("Installation type ${installation_type} requires and actual version string equivalent to that on github. Example: 0.13.0")
}

contain ::skydive::install
contain ::skydive::config

}
16 changes: 16 additions & 0 deletions manifests/install.pp
@@ -0,0 +1,16 @@
# class skydive::common::install
class skydive::install {

case $::skydive::installation_type {
'package': {
contain ::skydive::install::package
}
'web': {
contain ::skydive::install::web
}
default: {
fail("Well this is awkward, there's an issue with the validation of this module")
}
}

}
18 changes: 3 additions & 15 deletions manifests/install/agent.pp
@@ -1,21 +1,9 @@
# class skydive::install::agent
class skydive::install::agent {

case $::osfamily {
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
package { 'skydive-agent':
ensure => installed,
notify => Exec['skydive: reload systemd'],
}
} else {
package { 'skydive-agent':
ensure => installed,
}
}
}
default: {
fail("Module ${module_name} is not supported on osfamily '${::osfamily}'")
if $::skydive::installation_type == 'package' {
package { 'skydive-agent':
ensure => $::skydive::version,
}
}

Expand Down
18 changes: 3 additions & 15 deletions manifests/install/analyzer.pp
@@ -1,21 +1,9 @@
# class skydive::install::analyzer
class skydive::install::analyzer {

case $::osfamily {
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
package { 'skydive-analyzer':
ensure => installed,
notify => Exec['skydive: reload systemd'],
}
} else {
package { 'skydive-analyzer':
ensure => installed,
}
}
}
default: {
fail("Module ${module_name} is not supported on osfamily '${::osfamily}'")
if $::skydive::installation_type == 'package' {
package { 'skydive-analyzer':
ensure => $::skydive::version,
}
}

Expand Down
53 changes: 0 additions & 53 deletions manifests/install/common.pp

This file was deleted.

28 changes: 28 additions & 0 deletions manifests/install/package.pp
@@ -0,0 +1,28 @@
class skydive::install::package {

if $::skydive::manage_repo {
case $::osfamily {
'RedHat': {
yumrepo { 'opstools7-sensu-common-release':
baseurl => 'https://cbs.centos.org/repos/opstools7-sensu-common-release/$basearch/os/',
descr => 'Community Build Service',
enabled => '1',
gpgcheck => '0',
} ~>
exec { 'yum-clean-expire-cache':
command => '/usr/bin/yum clean expire-cache',
refreshonly => true,
}
}
default: {
fail("Module ${module_name} is not supported on osfamily '${::osfamily}'")
}
}
}

package { 'skydive':
ensure => $::skydive::version,
}


}
29 changes: 29 additions & 0 deletions manifests/install/web.pp
@@ -0,0 +1,29 @@
class skydive::install::web {

archive { '/usr/bin/skydive':
source => "https://github.com/skydive-project/skydive/releases/download/v${::skydive::version}/skydive",
extract => false,
cleanup => false,
checksum => $::skydive::web_checksum,
checksum_type => 'sha1',
}->
# Needed to make the binary executable
file { '/usr/bin/skydive':
ensure => file,
mode => '0550',
}

$skydive_packages = [
'skydive',
'skydive-agent',
'skydive-analyzer',
]

# Ensure Skydive packages are removed if already present
# Handy when switching over from a previous package install
package { $skydive_packages:
ensure => absent,
before => Archive['/usr/bin/skydive'],
}

}
3 changes: 3 additions & 0 deletions manifests/params.pp
Expand Up @@ -2,6 +2,9 @@
class skydive::params {

$manage_repo = true
$installation_type = 'web'
$version = '0.13.0'
$web_checksum = '34bbe7910d6086ae7a6b1f03dd52b84d2255e1fe'

$host_id = $::fqdn
$ws_pong_timeout = 5
Expand Down
36 changes: 30 additions & 6 deletions manifests/service/agent.pp
@@ -1,22 +1,46 @@
# class skydive::service::agent
class skydive::service::agent {

service { 'skydive-agent':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
case $::skydive::installation_type {
'web': {
service { 'skydive-agent':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
subscribe => [
Archive['/usr/bin/skydive'],
File['/usr/bin/skydive'],
],
}
}
default: {
service { 'skydive-agent':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
subscribe => Package['skydive'],
}
}
}

case $::osfamily {
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {

exec { 'skydive-agent: reload systemd':
command => 'systemctl daemon-reload',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
refreshonly => true,
}

file { '/etc/systemd/system/skydive-agent.service':
ensure => file,
mode => '0644',
source => 'puppet:///modules/skydive/service/systemd_agent',
notify => [
Exec['skydive: reload systemd'],
Exec['skydive-agent: reload systemd'],
Service['skydive-agent'],
],
}
Expand Down
36 changes: 30 additions & 6 deletions manifests/service/analyzer.pp
@@ -1,22 +1,46 @@
# class skydive::service::analyzer
class skydive::service::analyzer {

service { 'skydive-analyzer':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
case $::skydive::installation_type {
'web': {
service { 'skydive-analyzer':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
subscribe => [
Archive['/usr/bin/skydive'],
File['/usr/bin/skydive'],
],
}
}
default: {
service { 'skydive-analyzer':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
subscribe => Package['skydive'],
}
}
}

case $::osfamily {
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {

exec { 'skydive-analyzer: reload systemd':
command => 'systemctl daemon-reload',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
refreshonly => true,
}

file { '/etc/systemd/system/skydive-analyzer.service':
ensure => file,
mode => '0644',
source => 'puppet:///modules/skydive/service/systemd_analyzer',
notify => [
Exec['skydive: reload systemd'],
Exec['skydive-analyzer: reload systemd'],
Service['skydive-analyzer'],
],
}
Expand Down

0 comments on commit 844eb16

Please sign in to comment.