diff --git a/.fixtures.yml b/.fixtures.yml index 92436be..838325e 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,6 +2,5 @@ fixtures: repositories: inifile: https://github.com/puppetlabs/puppetlabs-inifile - staging: https://github.com/nanliu/puppet-staging symlinks: influxdb: "#{source_dir}" diff --git a/.gitignore b/.gitignore index 85e6787..f8ceb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +DEADJOE +*~ Gemfile.lock *.swp .librarian/ diff --git a/.travis.yml b/.travis.yml index fb77a9e..995b3bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,36 @@ ---- branches: only: - master + - repo-handling language: ruby rvm: + - 1.9.3 - 2.0.0 + - 2.1.0 +cache: bundler +sudo: false bundler_args: --without development -script: bundle exec rake spec SPEC_OPTS='--format documentation' +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" env: - matrix: - - PUPPET_VERSION="2.7.25" - - PUPPET_VERSION="3.1.1" - - PUPPET_VERSION="3.2.4" - - PUPPET_VERSION="3.3.2" - - PUPPET_VERSION="3.4.2" + - PUPPET_VERSION="~> 2.7.0" + - PUPPET_VERSION="~> 3.4.0" + - PUPPET_VERSION="~> 3.5.0" + - PUPPET_VERSION="~> 3.6.0" + - PUPPET_VERSION="~> 3.7.0" +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 3.0.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 3.1.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.3.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.4.0" notifications: email: - - justin@downing.us + - roman@plessl.info diff --git a/LICENSE b/LICENSE index 605f773..552df58 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,7 @@ +The MIT License (MIT) + Copyright (c) 2014 Justin Downing +Copyright (c) 2014-2015 Roman Plessl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/Puppetfile b/Puppetfile index cb63748..948c1b7 100644 --- a/Puppetfile +++ b/Puppetfile @@ -1,4 +1,3 @@ -forge 'http://forge.puppetlabs.com' +forge 'https://forgeapi.puppetlabs.com' -mod 'nanliu/staging', '>= 0.4.0' mod 'puppetlabs/inifile', '>= 1.0.0' diff --git a/Puppetfile.lock b/Puppetfile.lock index 26b5799..bd6b671 100644 --- a/Puppetfile.lock +++ b/Puppetfile.lock @@ -1,10 +1,8 @@ FORGE - remote: http://forge.puppetlabs.com + remote: https://forgeapi.puppetlabs.com specs: - nanliu/staging (0.4.0) - puppetlabs/inifile (1.0.3) + puppetlabs-inifile (1.2.0) DEPENDENCIES - nanliu/staging (>= 0.4.0) - puppetlabs/inifile (>= 1.0.0) + puppetlabs-inifile (>= 1.0.0) diff --git a/README.md b/README.md index 7ff4bd8..d881d0a 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,69 @@ -# influxdb +# puppet-influxdb -[![Puppet Forge](http://img.shields.io/puppetforge/v/jdowning/influxdb.svg)](https://forge.puppetlabs.com/jdowning/influxdb) [![Build Status](https://travis-ci.org/justindowning/puppet-influxdb.png)](https://travis-ci.org/justindowning/puppet-influxdb) +[![Build Status](https://travis-ci.org/rplessl/puppet-influxdb.png)](https://travis-ci.org/rplessl/puppet-influxdb) ## Description -This Puppet module will install [influxdb](https://influxdb.org) on Debian or RedHat. - -This module is still under active development so things are likely to change. If -you have any ideas or contributions, feel free to open a pull request! +puppet module to install and configure [influxdb](https://influxdb.org) (version 0.9.x and newer). Tested with InfluxDB 0.9.1 and 0.9.2. ## Installation -`puppet module install --modulepath /path/to/puppet/modules jdowning-influxdb` +`puppet module install --modulepath /path/to/puppet/modules puppet-influxdb` ## Usage +Basic default uses local package + `class { 'influxdb': }` -Most of the configuration is parameterized, so you can freely adjust settings. +Install the influx packages from InfluxDB upstream Amazon s3 packages. This is the default when not using a self managed repository +``` + class { 'influxdb': + install_from_repository => false, + } +``` +Alternativly you can install packages using your own url/proxy +``` + class { 'influxdb': + install_from_repository => false, + download_url => 'https://download.test.com/proxy/influxdb/influxdb-1.0.0.rpm' + } +``` + + +These configuration parameter can be set: +``` + $ensure = 'installed' + $version = 'latest' + $install_from_repository = true + $download_url = undef or https://download.test.com/influxdb.deb + $config_file = '/etc/opt/influxdb/influxdb.conf' + + # general section of influxb.conf + $reporting_disabled = false + + # [meta] + $meta_hostname = "localhost" or "192.168.0.1" + $meta_peers = undef or ["192.168.0.1:8088", "192.168.0.2:8088", "192.168.0.3:8088"] + + # [retention] + $retention_replication = undef or 3 +``` ## Testing +Install and setup vagrant [https://docs.vagrantup.com/v2/installation/index.html](as described here). + +Fetch virtual machines: +```ShellSession +vagrant box add puppetlabs/ubuntu-14.04-64-puppet --insecure +vagrant box add puppetlabs/centos-6.6-64-puppet --insecure +vagrant box add puppetlabs/centos-7.0-64-puppet --insecure +vagrant box add puppetlabs/debian-7.8-64-puppet --insecure ``` + +Add vagrant puppet support and run tests: +```ShellSession bundle install bundle exec librarian-puppet install vagrant up diff --git a/Rakefile b/Rakefile index 0f572fd..8647caa 100644 --- a/Rakefile +++ b/Rakefile @@ -1,9 +1,9 @@ require 'bundler' Bundler.require(:rake) +require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -require 'puppet_blacksmith/rake_tasks' Rake::Task[:lint].clear PuppetLint::RakeTask.new :lint do |config| diff --git a/Vagrantfile b/Vagrantfile index dc2442d..4cffa00 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,26 +1,60 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -Vagrant.configure("2") do |config| +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.hostname = 'puppet-influxdb' - config.vm.synced_folder "modules", "/tmp/puppet-modules", type: "rsync", rsync__exclude: ".git/" - config.vm.synced_folder ".", "/tmp/puppet-modules/influxdb", type: "rsync", rsync__exclude: ".git/" - config.vm.define "centos", primary: true do |centos| - centos.vm.box = "puppetlabs/centos-6.5-64-puppet" - centos.vm.provision :puppet do |puppet| + config.vm.box_download_insecure = true + + config.vm.synced_folder "modules", "/tmp/puppet-modules", type: "rsync", rsync__exclude: ".git/" + config.vm.synced_folder ".", "/tmp/puppet-modules/influxdb", type: "rsync", rsync__exclude: ".git/" + + config.vm.define "ubuntu", primary: true do |ubuntu| + ubuntu.vm.box = "puppetlabs/ubuntu-14.04-64-puppet" + ubuntu.vm.provision :puppet do |puppet| puppet.manifests_path = "tests" puppet.manifest_file = "vagrant.pp" puppet.options = ["--modulepath", "/tmp/puppet-modules"] end end - config.vm.define "ubuntu", autostart: false do |ubuntu| - ubuntu.vm.box = "puppetlabs/ubuntu-14.04-64-puppet" - ubuntu.vm.provision :puppet do |puppet| + config.vm.define "debian6", autostart: false do |debian6| + debian6.vm.box = "puppetlabs/debian-6.0.10-64-puppet" + debian6.vm.provision :puppet do |puppet| + puppet.manifests_path = "tests" + puppet.manifest_file = "vagrant.pp" + puppet.options = ["--modulepath", "/tmp/puppet-modules"] + end + end + + config.vm.define "debian", autostart: false do |debian| + debian.vm.box = "puppetlabs/debian-7.8-64-puppet" + debian.vm.provision :puppet do |puppet| puppet.manifests_path = "tests" puppet.manifest_file = "vagrant.pp" puppet.options = ["--modulepath", "/tmp/puppet-modules"] end end + + config.vm.define "centos6", autostart: false do |centos6| + centos6.vm.box = "puppetlabs/centos-6.6-64-puppet" + centos6.vm.provision :puppet do |puppet| + puppet.manifests_path = "tests" + puppet.manifest_file = "vagrant.pp" + puppet.options = ["--modulepath", "/tmp/puppet-modules"] + end + end + + config.vm.define "centos7", autostart: false do |centos7| + centos7.vm.box = "puppetlabs/centos-7.0-64-puppet" + centos7.vm.provision :puppet do |puppet| + puppet.manifests_path = "tests" + puppet.manifest_file = "vagrant.pp" + puppet.options = ["--modulepath", "/tmp/puppet-modules"] + end + end + end diff --git a/manifests/config.pp b/manifests/config.pp index ccc9147..993fc16 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,213 +1,47 @@ # == Class: influxdb::config -# More information on these settings available at: http://influxdb.org/docs/configuration.html +# +# only values which are effectivly changed will be managed +# More information on these settings available at: +# https://influxdb.com/docs/v0.9/administration/config.html +# +# DO NO CALL DIRECTLY class influxdb::config { - ini_setting { 'hostname': - section => '', - setting => 'hostname', - value => "\"${influxdb::hostname}\"", - } - - ini_setting { 'bind_address': - section => '', - setting => 'bind-address', - value => "\"${influxdb::bind_address}\"", - } - - # [logging] - ini_setting { 'logging_level': - section => 'logging', - setting => 'level', - value => "\"${influxdb::logging_level}\"", - } - - ini_setting { 'logging_file': - section => 'logging', - setting => 'file', - value => "\"${influxdb::logging_file}\"", - } - - # [admin] - ini_setting { 'admin_port': - section => 'admin', - setting => 'port', - value => $influxdb::admin_port, - } - - ini_setting { 'admin_assets': - section => 'admin', - setting => 'assets', - value => "\"${influxdb::admin_assets}\"", - } - - # [api] - ini_setting { 'api_port': - section => 'api', - setting => 'port', - value => $influxdb::api_port, - } - - ini_setting { 'api_read_timeout': - section => 'api', - setting => 'read-timeout', - value => "\"${influxdb::api_read_timeout}\"", - } - - # [raft] - ini_setting { 'raft_port': - section => 'raft', - setting => 'port', - value => $influxdb::raft_port, - } - - ini_setting { 'raft_dir': - section => 'raft', - setting => 'dir', - value => "\"${influxdb::raft_dir}\"", - } - - ini_setting { 'raft_election_timeout': - section => 'raft', - setting => 'election-timeout', - value => "\"${influxdb::raft_election_timeout}\"", - } - - # [storage] - ini_setting { 'storage_dir': - section => 'storage', - setting => 'dir', - value => "\"${influxdb::storage_dir}\"", - } - - ini_setting { 'storage_write_buffer_size': - section => 'storage', - setting => 'write-buffer-size', - value => $influxdb::storage_write_buffer_size, - } - - # [cluster] - ini_setting { 'cluster_seed_servers': - section => 'cluster', - setting => 'seed-servers', - value => $influxdb::cluster_seed_servers, - } - - ini_setting { 'cluster_protobuf_port': - section => 'cluster', - setting => 'protobuf_port', - value => $influxdb::cluster_protobuf_port, - } - - ini_setting { 'cluster_protobuf_timeout': - section => 'cluster', - setting => 'protobuf_timeout', - value => "\"${influxdb::cluster_protobuf_timeout}\"", - } - - ini_setting { 'cluster_protobuf_heartbeat': - section => 'cluster', - setting => 'protobuf_heartbeat', - value => "\"${influxdb::cluster_protobuf_heartbeat}\"", - } - - ini_setting { 'cluster_protobuf_min_backoff': - section => 'cluster', - setting => 'protobuf_min_backoff', - value => "\"${influxdb::cluster_protobuf_min_backoff}\"", - } - - ini_setting { 'cluster_protobuf_max_backoff': - section => 'cluster', - setting => 'protobuf_max_backoff', - value => "\"${influxdb::cluster_protobuf_max_backoff}\"", - } - - ini_setting { 'cluster_write_buffer_size': - section => 'cluster', - setting => 'write-buffer-size', - value => $influxdb::cluster_write_buffer_size, - } - - ini_setting { 'cluster_max_response_buffer_size': - section => 'cluster', - setting => 'max-response-buffer-size', - value => $influxdb::cluster_max_response_buffer_size, - } - - ini_setting { 'cluster_concurrent_shard_query_limit': - section => 'cluster', - setting => 'concurrent-shard-query-limit', - value => $influxdb::cluster_concurrent_shard_query_limit, - } - - # [leveldb] - ini_setting { 'leveldb_max_open_files': - section => 'leveldb', - setting => 'max-open-files', - value => $influxdb::leveldb_max_open_files, - } - - ini_setting { 'leveldb_lru_cache_size': - section => 'leveldb', - setting => 'lru-cache-size', - value => "\"${influxdb::leveldb_lru_cache_size}\"", - } - ini_setting { 'leveldb_max_open_shards': - section => 'leveldb', - setting => 'max-open-shards', - value => $influxdb::leveldb_max_open_shards, - } - - ini_setting { 'leveldb_point_batch_size': - section => 'leveldb', - setting => 'point-batch-size', - value => $influxdb::leveldb_point_batch_size, - } - - ini_setting { 'leveldb_point_write_size': - section => 'leveldb', - setting => 'point-write-size', - value => $influxdb::leveldb_point_write_size, - } - - # [sharding] - - # [wal] - ini_setting { 'wal_dir': - section => 'wal', - setting => 'dir', - value => "\"${influxdb::wal_dir}\"", + # defaults for all settings + Ini_setting { + ensure => present, + path => $influxdb::config_file, } - ini_setting { 'wal_flush_after': - section => 'wal', - setting => 'flush-after', - value => $influxdb::wal_flush_after, + # specific changes + ini_setting { 'reporting-disabled': + section => '', + setting => 'reporting-disabled', + value => $influxdb::reporting_disabled, } - ini_setting { 'wal_bookmark_after': - section => 'wal', - setting => 'bookmark-after', - value => $influxdb::wal_bookmark_after, + # [meta] + ini_setting { 'meta_hostname': + section => 'meta', + setting => 'hostname', + value => "\"${influxdb::meta_hostname}\"", } - ini_setting { 'wal_index_after': - section => 'wal', - setting => 'index-after', - value => $influxdb::wal_index_after, + if $influxdb::meta_peers != undef { + ini_setting { 'meta_peers': + section => 'meta', + setting => 'peers', + value => $influxdb::meta_peers, + } } - ini_setting { 'wal_requests_per_logfile': - section => 'wal', - setting => 'requests-per-logfile', - value => $influxdb::wal_requests_per_logfile, + if $influxdb::retention_replication != undef { + # [retention] + ini_setting { 'retention_replication': + section => 'retention', + setting => 'replication', + value => $influxdb::retention_replication, + } } - # defaults for all settings - Ini_setting { - ensure => present, - path => $influxdb::config_path, - notify => Service['influxdb'], - require => Package['influxdb'], - } } diff --git a/manifests/init.pp b/manifests/init.pp index 929c9b4..0ccc67b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,45 +1,18 @@ # == Class: influxdb class influxdb ( - $ensure = $influxdb::params::ensure, - $version = $influxdb::params::version, - $install_from_repository = $influxdb::params::install_from_repository, - $config_path = $influxdb::params::config_path, - $hostname = $influxdb::params::hostname, - $bind_address = $influxdb::params::bind_address, - $logging_level = $influxdb::params::logging_level, - $logging_file = $influxdb::params::logging_file, - $admin_port = $influxdb::params::admin_port, - $admin_assets = $influxdb::params::admin_assets, - $api_port = $influxdb::params::api_port, - $api_read_timeout = $influxdb::params::api_read_timeout, - $raft_port = $influxdb::params::raft_port, - $raft_dir = $influxdb::params::raft_dir, - $raft_election_timeout = $influxdb::params::raft_election_timeout, - $storage_dir = $influxdb::params::storage_dir, - $storage_write_buffer_size = $influxdb::params::storage_write_buffer_size, - $cluster_seed_servers = $influxdb::params::cluster_seed_servers, - $cluster_protobuf_port = $influxdb::params::cluster_protobuf_port, - $cluster_protobuf_timeout = $influxdb::params::cluster_protobuf_timeout, - $cluster_protobuf_heartbeat = $influxdb::params::cluster_protobuf_heartbeat, - $cluster_protobuf_min_backoff = $influxdb::params::cluster_protobuf_min_backoff, - $cluster_protobuf_max_backoff = $influxdb::params::cluster_protobuf_max_backoff, - $cluster_write_buffer_size = $influxdb::params::cluster_write_buffer_size, - $cluster_max_response_buffer_size = $influxdb::params::cluster_max_response_buffer_size, - $cluster_concurrent_shard_query_limit = $influxdb::params::cluster_concurrent_shard_query_limit, - $leveldb_max_open_files = $influxdb::params::leveldb_max_open_files, - $leveldb_lru_cache_size = $influxdb::params::leveldb_lru_cache_size, - $leveldb_max_open_shards = $influxdb::params::leveldb_max_open_shards, - $leveldb_point_batch_size = $influxdb::params::leveldb_point_batch_size, - $leveldb_write_batch_size = $influxdb::params::leveldb_write_batch_size, - $wal_dir = $influxdb::params::wal_dir, - $wal_flush_after = $influxdb::params::wal_flush_after, - $wal_bookmark_after = $influxdb::params::wal_bookmark_after, - $wal_index_after = $influxdb::params::wal_index_after, - $wal_requests_per_logfile = $influxdb::params::wal_requests_per_logfile, + $ensure = $influxdb::params::ensure, + $version = $influxdb::params::version, + $install_from_repository = $influxdb::params::install_from_repository, + $config_file = $influxdb::params::config_file, + $reporting_disabled = $influxdb::params::reporting_disabled, + $meta_hostname = $influxdb::params::meta_hostname, + $meta_peers = $influxdb::params::meta_peers, + $retention_replication = $influxdb::params::retention_replication, + $download_url = $influxdb::params::download_url, ) inherits influxdb::params { - class { 'influxdb::config': } - class { 'influxdb::install': } - class { 'influxdb::service': } - + class { 'influxdb::install': } -> + class { 'influxdb::config': } ~> + class { 'influxdb::service': } -> + Class['influxdb'] } diff --git a/manifests/install.pp b/manifests/install.pp index 8136598..34c5a66 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,41 +1,93 @@ # == Class: influxdb::install # DO NO CALL DIRECTLY class influxdb::install { - package { 'influxdb': - ensure => $influxdb::ensure, + $package_ensure = $influxdb::ensure + case $package_ensure { + true: { + $my_package_ensure = 'present' + } + false: { + $my_package_ensure = 'absent' + } + 'absent': { + $my_package_ensure = 'absent' + } + 'purged': { + $my_package_ensure = 'purged' + } + default: { + $my_package_ensure = $package_ensure + } } - if !$influxdb::install_from_repository { + + if ((!$influxdb::install_from_repository) and ("$my_package_ensure" =~ /present|installed/ )) { # package source and provider case $::osfamily { 'Debian': { - $package_provider = 'dpkg' - $package_source = $::architecture ? { - /64/ => "http://s3.amazonaws.com/influxdb/influxdb_${influxdb::version}_amd64.deb", - default => "http://s3.amazonaws.com/influxdb/influxdb_${influxdb::version}_i386.deb", + $package_source_name = $::architecture ? { + /386/ => "influxdb_${influxdb::version}_i386.deb", + default => "influxdb_${influxdb::version}_amd64.deb", + } + if $influxdb::download_url != undef { + $package_source = $influxdb::download_url + } + else { + $package_source = "http://influxdb.s3.amazonaws.com/${package_source_name}" + } + exec { + 'influxdb_wget': + command => "wget ${package_source} -O /tmp/${package_source_name}", + path => ['/bin', '/usr/bin'], + unless => 'dpkg --list influxdb'; + + 'influxdb_dpkg': + command => "sudo dpkg -i /tmp/${package_source_name}", + path => ['/bin', '/sbin', '/usr/bin'], + require => [ Exec['influxdb_wget'] ]; + + 'influxdb_rm': + command => "rm /tmp/${package_source_name}", + path => ['/bin', '/usr/bin'], + require => [ Exec['influxdb_dpkg'] ]; + + 'influxdb_from_web': + command => "echo Installed ${package_source_name} on `date --rfc-2822` > /opt/influxdb/versions/influxdb_from_web", + path => ['/bin', '/usr/bin'], + require => [ Exec['influxdb_dpkg'] ]; } } 'RedHat', 'Amazon': { - $package_provider = 'rpm' - $package_source = $::architecture ? { - /64/ => "http://s3.amazonaws.com/influxdb/influxdb-${influxdb::version}-1.x86_64.rpm", - default => "http://s3.amazonaws.com/influxdb/influxdb-${influxdb::version}-1.i686.rpm", + $package_source_name = $::architecture ? { + /386/ => "influxdb-${influxdb::version}-1.i686.rpm", + default => "influxdb-${influxdb::version}-1.x86_64.rpm", + } + if $influxdb::download_url != undef { + $package_source = $influxdb::download_url + } + else { + $package_source = "http://influxdb.s3.amazonaws.com/${package_source_name}" + } + exec { + 'influxdb_rpm': + command => "rpm -ivh ${package_source}", + path => ['/bin', '/usr/bin'], + unless => 'rpm -qa | grep influxdb'; + + 'influxdb_from_web': + command => "echo Installed ${package_source_name} on `date --rfc-2822` > /opt/influxdb/versions/influxdb_from_web", + path => ['/bin', '/usr/bin'], + require => [ Exec['influxdb_rpm'] ]; } } default: { - fail('Only supports Debian or RedHat $::osfamily') + fail('Only supports Debian / Ubuntu or RedHat $::osfamily') } } - - # get the package - staging::file { 'influxdb-package': - source => $package_source, - } - - # install the package - Package['influxdb']{ - provider => $package_provider, - source => '/opt/staging/influxdb/influxdb-package', - require => Staging::File['influxdb-package'], + } + else { + # install / purge the package + package { 'influxdb': + ensure => $my_package_ensure, } } } diff --git a/manifests/params.pp b/manifests/params.pp index 003d5df..8fd8cd0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,61 +1,20 @@ # == Class: influxdb::params # DO NOT CALL DIRECTLY class influxdb::params { - $ensure = 'installed' - $version = 'latest' - $install_from_repository = false - $config_path = '/opt/influxdb/shared/config.toml' + $ensure = 'installed' + $version = '0.9.2' + $install_from_repository = true + $config_file = '/etc/opt/influxdb/influxdb.conf' - $hostname = $::hostname - $bind_address = '0.0.0.0' + $download_url = undef + # general section of influxdb.conf + $reporting_disabled = false - # [logging] - $logging_level = 'info' - $logging_file = '/opt/influxdb/shared/influxdb.log' + # [meta] + $meta_hostname = 'localhost' + $meta_peers = undef - # [admin] - $admin_port = '8083' - $admin_assets = '/opt/influxdb/current/admin' + # [retention] + $retention_replication = undef - # [api] - $api_port = '8086' - $api_read_timeout = '5s' - - # [input_plugins] - - # [raft] - $raft_port = '8090' - $raft_dir = '/opt/influxdb/shared/data/raft' - $raft_election_timeout = '1s' - - # [storage] - $storage_dir = '/opt/influxdb/shared/data/db' - $storage_write_buffer_size = '10000' - - # [cluster] - $cluster_seed_servers = '[]' - $cluster_protobuf_port = '8099' - $cluster_protobuf_timeout = '2s' - $cluster_protobuf_heartbeat = '200ms' - $cluster_protobuf_min_backoff = '1s' - $cluster_protobuf_max_backoff = '10s' - $cluster_write_buffer_size = '10000' - $cluster_max_response_buffer_size = '100' - $cluster_concurrent_shard_query_limit = '10' - - # [leveldb] - $leveldb_max_open_files = '40' - $leveldb_lru_cache_size = '200m' - $leveldb_max_open_shards = '0' - $leveldb_point_batch_size = '100' - $leveldb_point_write_size = '5000000' - - # [sharding] - - # [wal] - $wal_dir = '/opt/influxdb/shared/data/wal' - $wal_flush_after = '0' - $wal_bookmark_after = '0' - $wal_index_after = '1000' - $wal_requests_per_logfile = '10000' } diff --git a/manifests/service.pp b/manifests/service.pp index 80b45ec..7c989f2 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -5,6 +5,6 @@ ensure => running, enable => true, hasrestart => true, - require => Package['influxdb'], + status => '/usr/bin/pgrep -u influxdb -f "/opt/influxdb/influxd "' } } diff --git a/metadata.json b/metadata.json index 32db868..c46f707 100644 --- a/metadata.json +++ b/metadata.json @@ -1,40 +1,45 @@ { - "name": "jdowning-influxdb", - "version": "0.3.0", - "source": "https://github.com/justindowning/puppet-influxdb", - "author": "Justin Downing", - "license": "Apache License, Version 2.0", - "summary": "Setup and manage influxdb", - "description": "Setup and manage influxdb", - "project_page": "https://github.com/justindowning/puppet-influxdb", + "name": "rplessl-influxdb", + "version": "0.9.2", + "source": "https://github.com/rplessl/puppet-influxdb", + "author": "Justin Downing and Roman Plessl", + "license": "MIT License", + "summary": "Setup and manage influxdb 0.9.x", + "description": "Setup and manage influxdb 0.9.x", + "source": "git://github.com/rplessl/puppet-influxdb.git", + "project_page": "https://github.com/rplessl/puppet-influxdb", + "issues_url": "https://github.com/rplessl/puppet-influxdb/issues", + "tags": [ + "influxdb", + "monitoring" + ], "dependencies": [ - { "name": "nanliu/staging", "version_requirement": ">= 0.4.0" }, { "name": "puppetlabs/inifile", "version_requirement": ">= 1.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "RedHat", - "operatingsystemrelease": [ "5", "6" ] + "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "CentOS", - "operatingsystemrelease": [ "5", "6" ] + "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ "5", "6" ] + "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Scientific", - "operatingsystemrelease": [ "5", "6" ] + "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Debian", - "operatingsystemrelease": [ "6", "7" ] + "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] + "operatingsystemrelease": [ "12.04", "14.04" ] } ], "requirements": [ diff --git a/spec/classes/influxdb_config_spec.rb b/spec/classes/influxdb_config_spec.rb new file mode 100644 index 0000000..b9abf46 --- /dev/null +++ b/spec/classes/influxdb_config_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'influxdb::config', :type => :class do + + it { should create_class('influxdb::config') } + + context 'with default preset variables' do + let(:pre_condition) { + 'class{"influxdb" : + install_from_repository => true, + config_file => "/etc/opt/influxdb/influxdb.conf" + }' + } + + end +end diff --git a/spec/classes/influxdb_init_spec.rb b/spec/classes/influxdb_init_spec.rb new file mode 100644 index 0000000..9639eca --- /dev/null +++ b/spec/classes/influxdb_init_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe 'influxdb', :type => 'class' do + + it { should contain_class('influxdb::params') } + it { should create_class('influxdb') } + +end diff --git a/spec/classes/influxdb_install_spec.rb b/spec/classes/influxdb_install_spec.rb new file mode 100644 index 0000000..016e379 --- /dev/null +++ b/spec/classes/influxdb_install_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper' + +describe 'influxdb::install', :type => :class do + + it { should create_class('influxdb::install') } + + context 'installing from a repository' do + let(:pre_condition) { + 'class{"influxdb": + ensure => "installed", + install_from_repository => true, + }' + } + context 'on debian' do + let(:facts) { + { + :osfamily => 'Debian', + :architecture => 'x86_64', + } + } + it { should contain_package('influxdb').with( + :ensure => 'installed', + )} + end + context 'on redhat' do + let(:facts) { + { + :osfamily => 'RedHat', + :architecture => 'x86_64', + } + } + it { should contain_package('influxdb').with( + :ensure => 'installed', + )} + end + end + + context 'installing from web' do + context 'with default preset url' do + let(:pre_condition) { + 'class{"influxdb": + ensure => "installed", + install_from_repository => false, + }' + } + context 'on Debian' do + let(:facts) { + { + :osfamily => 'Debian', + :architecture => 'x86_64', + } + } + it { should contain_exec('influxdb_wget') + .with_command(/influxdb.s3.amazonaws/) + } + end + context 'on redhat' do + let(:facts) { + { + :osfamily => 'RedHat', + :architecture => 'x86_64', + } + } + context 'with default preset url' do + it { should contain_exec('influxdb_rpm') + .with_command(/influxdb.s3.amazonaws/) + } + end + end + end + + context 'with download_url set' do + let(:pre_condition) { + 'class{"influxdb": + ensure => "installed", + install_from_repository => false, + download_url => "https://download.test.com/proxy/influxdb/influxdb-1.0.0.rpm" + }' + } + context 'on Debian' do + let(:facts) { + { + :osfamily => 'Debian', + :architecture => 'x86_64', + } + } + it { should contain_exec('influxdb_wget') + .with_command(/download.test.com/) + } + end + context 'on redhat' do + let(:facts) { + { + :osfamily => 'RedHat', + :architecture => 'x86_64', + } + } + context 'with default preset url' do + it { should contain_exec('influxdb_rpm') + .with_command(/download.test.com/) + } + end + end + end + end + + + it { should contain_package('influxdb') } + +end diff --git a/spec/classes/influxdb_service_spec.rb b/spec/classes/influxdb_service_spec.rb new file mode 100644 index 0000000..68f0d93 --- /dev/null +++ b/spec/classes/influxdb_service_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe 'influxdb::service', :type => :class do + + it { should create_class('influxdb::service') } + it { should contain_service('influxdb').with( + 'ensure' => 'running', + 'enable' => true + ) } +end diff --git a/spec/classes/influxdb_spec.rb b/spec/classes/influxdb_spec.rb deleted file mode 100644 index 87d293f..0000000 --- a/spec/classes/influxdb_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'influxdb', :type => 'class' do - let(:facts) { { :osfamily => 'Debian' } } - - it { should contain_class("influxdb::params") } - - it { should contain_influxdb__config } - it { should contain_influxdb__install } - it { should contain_influxdb__service } - -end diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb deleted file mode 100644 index 3a520c4..0000000 --- a/spec/classes/install_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -require 'spec_helper' - -describe 'influxdb::install' do - context 'with default params' do - let(:pre_condition) { - 'include influxdb' - } - context 'on debian' do - let(:facts) { - { - :osfamily => 'Debian', - :architecture => 'x86_64', - } - } - - it { should contain_staging__file('influxdb-package').with( - :source => 'http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb', - )} - - it { should contain_package('influxdb').with( - :ensure => 'installed', - :provider => 'dpkg', - :source => '/opt/staging/influxdb/influxdb-package', - :require => 'Staging::File[influxdb-package]', - )} - end - context 'on redhat' do - let(:facts) { - { - :osfamily => 'RedHat', - :architecture => 'x86_64', - } - } - - it { should contain_staging__file('influxdb-package').with( - :source => 'http://s3.amazonaws.com/influxdb/influxdb-latest-1.x86_64.rpm', - )} - - it { should contain_package('influxdb').with( - :ensure => 'installed', - :provider => 'rpm', - :source => '/opt/staging/influxdb/influxdb-package', - :require => 'Staging::File[influxdb-package]', - )} - end - end - context 'installing from a repository' do - let(:pre_condition) { - 'class{"influxdb": - install_from_repository => true, - }' - } - context 'on debian' do - let(:facts) { - { - :osfamily => 'Debian', - :architecture => 'x86_64', - } - } - - it { should_not contain_staging__file('influxdb-package') } - it { should contain_package('influxdb').with( - :ensure => 'installed', - )} - end - context 'on redhat' do - let(:facts) { - { - :osfamily => 'RedHat', - :architecture => 'x86_64', - } - } - - it { should_not contain_staging__file('influxdb-package') } - it { should contain_package('influxdb').with( - :ensure => 'installed', - )} - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3923f8..5d8ae92 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,11 @@ +require 'rubygems' +require 'puppetlabs_spec_helper/module_spec_helper' + require 'rspec-puppet' +# This will make stdlib functions available when test examples will run +$:.unshift File.join(File.dirname(__FILE__), 'fixtures', 'modules', 'stdlib', 'lib') + fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| diff --git a/tests/vagrant.pp b/tests/vagrant.pp index 782add4..b9f3044 100644 --- a/tests/vagrant.pp +++ b/tests/vagrant.pp @@ -1 +1,4 @@ -class { 'influxdb': } +class { + 'influxdb': + install_from_repository => false; +}