diff --git a/.fixtures.yml b/.fixtures.yml index 17b587bb..3b93b21e 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,5 @@ fixtures: repositories: - stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" + stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" symlinks: - graphite: "#{source_dir}" \ No newline at end of file + graphite: "#{source_dir}" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..db111acd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +* text=auto + +# Templates need to always use *nix-style line endings, as they can sometimes +# be copied from a Windows machine to a *nix machine and used there (such as +# when running Beaker tests on a Windows host). +templates/** eol=lf diff --git a/CHANGELOG.md b/CHANGELOG.md index face7661..47a321be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## 2017-03-17 - 7.0.0 (Major release) + +#### Features: + +- Add support for Ubuntu Xenial (see compatibility part of README) +- Add the ability to specify an alternative python binary +- Allow setting service provider by parameter +- Make logrotation optional +- Autodetect additional whisper dirs +- Optimizations for Amazon Linux +- Add parameter gr_carbon_log_rotate + +#### Bugfixes: + +- Some smaller fixes + ## 2016-05-31 - 6.0.4 (Bugfix release) #### Bugfixes: diff --git a/Gemfile b/Gemfile index fef97e45..df38e073 100644 --- a/Gemfile +++ b/Gemfile @@ -10,15 +10,32 @@ def location_for(place, version = nil) end end -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 4') -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'] || '~> 2') gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false gem 'puppet-lint', '>= 0.3.2', :require => false gem 'rspec-puppet', '>= 2.3.2', :require => false gem 'rspec-puppet-facts', :require => false gem 'metadata-json-lint', :require => false -gem 'rake', '< 11.0.0' # rubi <1.9 versus rake 11.0.0 workaround +# rubi <1.9 versus rake 11.0.0 workaround +gem 'rake', '< 11.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') +gem 'json', '< 2.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') +gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) + +# Only explicitly specify Facter/Hiera if a version has been specified. +# Otherwise it can lead to strange bundler behavior. If you are seeing weird +# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable +# to `1` and then run bundle install. +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] +gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] + + +# Evaluate Gemfile.local if it exists if File.exists? "#{__FILE__}.local" eval(File.read("#{__FILE__}.local"), binding) end + +# Evaluate ~/.gemfile if it exists +if File.exists?(File.join(Dir.home, '.gemfile')) + eval(File.read(File.join(Dir.home, '.gemfile')), binding) +end diff --git a/README.md b/README.md index 1e56bcfb..517a288e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -#graphite +# graphite -####Table of Contents +#### Table of Contents 1. [Overview - What is the graphite module?](#overview) 2. [Module Description - What does this module do?](#module-description) @@ -17,7 +17,7 @@ 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Contributing to the graphite module](#contributing) -##Overview +## Overview This module installs and makes basic configs for graphite, with carbon and whisper. @@ -25,18 +25,18 @@ This module installs and makes basic configs for graphite, with carbon and whisp [![Build Status](https://secure.travis-ci.org/echocat/puppet-graphite.png?branch=master)](https://travis-ci.org/echocat/puppet-graphite) [![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/dwerder/graphite.svg)](https://forge.puppetlabs.com/dwerder/graphite) -##Module Description +## Module Description [Graphite](http://graphite.readthedocs.org/en/latest/overview.html), and its components Carbon and Whisper, is an enterprise-scale monitoring tool. This module sets up a simple graphite server with all its components. Furthermore it can be used to set up more complex graphite environments with metric aggregation, clustering and so on. -##Setup +## Setup **What graphite affects:** * packages/services/configuration files for Graphite * on default sets up webserver (can be disabled if manage by other module) -###Beginning with Graphite +### Beginning with Graphite To install Graphite with default parameters @@ -46,7 +46,7 @@ To install Graphite with default parameters The defaults are determined by your operating system e.g. Debian systems have one set of defaults, and RedHat systems have another). This defaults should work well on testing environments with graphite as a standalone service on the machine. For production use it is recommend to use a database like MySQL and cache data in memcached (not installed with this module) and configure it here. Furthermore you should check things like `gr_storage_schemas`. -###Configure MySQL and Memcached +### Configure MySQL and Memcached ```puppet class { 'graphite': @@ -80,14 +80,14 @@ The defaults are determined by your operating system e.g. Debian systems have on } ``` -###Configure Graphite with Grafana +### Configure Graphite with Grafana This setup will use the [puppetlabs-apache](https://forge.puppetlabs.com/puppetlabs/apache) and [bfraser-grafana](https://forge.puppet.com/bfraser/grafana) modules to setup a graphite system with grafana frontend. You will also need an elasticsearch as it is required for grafana. ```puppet include '::apache' -apache::vhost { graphite.my.domain: +apache::vhost { 'graphite.my.domain': port => '80', docroot => '/opt/graphite/webapp', wsgi_application_group => '%{GLOBAL}', @@ -128,7 +128,7 @@ class {'grafana': } ``` -###Configuration with Apache 2.4 and CORS +### Configuration with Apache 2.4 and CORS If you use a system which ships Apache 2.4, then you will need a slightly different vhost config. Here is an example with Apache 2.4 and [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) enabled. @@ -142,7 +142,7 @@ If you do not know what CORS, then do not use it. Its disabled by default. You w } ``` -###Configuration with Additional LDAP Options +### Configuration with Additional LDAP Options If additional LDAP parameters are needed for your Graphite installation, you can specify them using the `gr_ldap_options` parameter. For example, this is useful if you're using SSL and need to configure LDAP to use your SSL cert and key files. @@ -172,7 +172,7 @@ ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW) See http://www.python-ldap.org/ for more details about these options. -###Configuration with multiple cache, relay and/or aggregator instances +### Configuration with multiple cache, relay and/or aggregator instances You could create more than one instance for cache, relay or aggregator using the `gr_cache_instances`, `gr_relay_instances` and `gr_aggregator_instances` parameters. These paremeters must be hashes, and the keys are the name of the instances (cache:b, cache:c, relay:b, relay:c, etc.). Every hash must have an array of parameters which will be written as is in the config file. The defaults settings for the additional instances will be the @@ -201,7 +201,7 @@ ones set for the principal instance. So in this case you would have 3 cache instances, the first one is `cache` (you can refer to it as `cache:a` too), `cache:b` and `cache:c`. cache:a will listen on ports 2003, 2004 and 7002 for line, pickle and query respectively. But, cache:b will do it on ports 2103, 2104, and 7102, and cache:c on 2203, 2204 and 7202. All other parameters from cache:a will be inherited by cache:b and c. -###Installing with something other than pip and specifying package names and versions +### Installing with something other than pip and specifying package names and versions If you need to install via something other than pip, an internal apt repo with fpm converted packages for instance, you can set `gr_pip_install` to false. If you're doing this you'll most likely have to override the default package names and versions as well. ```puppet @@ -231,7 +231,7 @@ Additionally, the Django package is normally installed from a system package, bu } ``` -####Managing system pip and Python development packages +#### Managing system pip and Python development packages If gr_pip_install is set to true, both python-pip and Python development packages will need to be installed. If you want to manage those packages separately, set gr_manage_python_packages to false. @@ -240,165 +240,188 @@ If gr_pip_install is set to true, both python-pip and Python development package gr_manage_python_packages => false, } -##Usage +### Installing with pip from a non-PyPI source -####Class: `graphite` +You can also chose to install the pip packages from a source other than PyPI, such as a file on disk or an HTTP server. If you do this you will also have to set the package versions to `'present'` to avoid errors from Puppet: +```puppet + class { '::graphite': + gr_django_tagging_ver => 'present', + gr_django_tagging_source => 'http://example.com/django-tagging-0.3.1.tar.gz', + gr_twisted_ver => 'present', + gr_twisted_source => 'http://example.com/Twisted-11.1.0.tar.bz2', + gr_txamqp_ver => 'present', + gr_txamqp_source => 'http://example.com/txAMQP-0.4.tar.gz', + gr_graphite_ver => 'present', + gr_graphite_source => 'http://example.com/graphite-web-0.9.15.tar.gz', + gr_carbon_ver => 'present', + gr_carbon_source => 'http://example.com/carbon-0.9.15.tar.gz', + gr_whisper_ver => 'present', + gr_whisper_source => 'http://example.com/whisper-0.9.15.tar.gz', + } +``` + +## Usage + +#### Class: `graphite` This is the primary class. And the only one which should be used. **Parameters within `graphite`:** -#####`gr_group` +##### `gr_group` Default is empty. The group of the user (see gr_user) who runs graphite. -#####`gr_user` +##### `gr_user` Default is empty. The user who runs graphite. If this is empty carbon runs as the user that invokes it. -#####`gr_enable_carbon_cache` +##### `gr_enable_carbon_cache` Default is true. Enable carbon cache. -#####`gr_max_cache_size` +##### `gr_max_cache_size` Default is 'inf'. Limits the size of the cache to avoid swapping or becoming CPU bound. Use the value "inf" (infinity) for an unlimited cache size. -#####`gr_max_updates_per_second` +##### `gr_max_updates_per_second` Default is 500. Limits the number of whisper update_many() calls per second, which effectively means the number of write requests sent to the disk. -#####`gr_max_updates_per_second_on_shutdown` +##### `gr_max_updates_per_second_on_shutdown` Default is 'undef' (no limit change on shutdown). Change the limits of gr_max_updates_per_second in case of an stop/shutdown event to speed up/slow down the shutdown process. -#####`gr_max_creates_per_minute` +##### `gr_max_creates_per_minute` Default is 50. Softly limits the number of whisper files that get created each minute. -#####`gr_carbon_metric_prefix` +##### `gr_carbon_metric_prefix` The prefix to be applied to internal performance metrics. Defaults to 'carbon'. -#####`gr_carbon_metric_interval` +##### `gr_carbon_metric_interval` Default is 60. Set the interval between sending internal performance metrics; affects all carbon daemons. -#####`gr_carbon_relay_ulimit` +##### `gr_carbon_relay_ulimit` Default is undef. Set the maximum number of file descriptors for carbon-relay process. -#####`gr_line_receiver_interface` +##### `gr_line_receiver_interface` Default is '0.0.0.0' (string). Interface the line receiver listens. -#####`gr_line_receiver_port` +##### `gr_line_receiver_port` Default is 2003. Port of line receiver. -#####`gr_enable_udp_listener` +##### `gr_enable_udp_listener` Default is 'False' (string). Set this to True to enable the UDP listener. -#####`gr_udp_receiver_interface` +##### `gr_udp_receiver_interface` Default is '0.0.0.0' (string). Its clear, isnt it? -#####`gr_udp_receiver_port` +##### `gr_udp_receiver_port` Default is 2003. Self explaining. -#####`gr_pickle_receiver_interface` +##### `gr_pickle_receiver_interface` Default is '0.0.0.0' (string). Pickle is a special receiver who handle tuples of data. -#####`gr_pickle_receiver_port` +##### `gr_pickle_receiver_port` Default is 2004. Self explaining -#####`gr_log_listener_connections` +##### `gr_log_listener_connections` Default is 'True' (string). Logs successful connections -#####`gr_use_insecure_unpickler` +##### `gr_use_insecure_unpickler` Default is 'False' (string). Set this to 'True' to revert to the old-fashioned insecure unpickler. -#####`gr_use_whitelist` +##### `gr_use_whitelist` Default is 'False' (string). Set this to 'True' to enable whitelists and blacklists. -#####`gr_whitelist` +##### `gr_whitelist` List of patterns to be included in whitelist.conf. Default is [ '.*' ]. -#####`gr_blacklist` +##### `gr_blacklist` List of patterns to be included in blacklist.conf. Default is [ ]. -#####`gr_cache_query_interface` +##### `gr_cache_query_interface` Default is '0.0.0.0'. Interface to send cache queries to. -#####`gr_cache_query_port` +##### `gr_cache_query_port` Default is 7002. Self explaining. -#####`gr_timezone` +##### `gr_timezone` Default is 'GMT' (string). Timezone for graphite to be used. -#####`gr_base_dir` +##### `gr_base_dir` Default is '/opt/graphite'. Set base install location of Graphite. This forms the base location for installs, predominantly appropriate for pip installations. When not installing using pip a typical location for this may be '/opt/carbon'. -#####`gr_storage_dir` +##### `gr_storage_dir` Default is '${gr_base_dir}/storage'. Set location of base storage files. When not installing using pip a typical location for this may be '/opt/carbon'. This dir is also used as pid dir on RedHat. -#####`gr_local_data_dir` +##### `gr_local_data_dir` Default is '${gr_storage_dir}/whisper'. Set location of whisper files. -#####`gr_rrd_dir` +##### `gr_rrd_dir` Default is '${gr_storage_dir}/rrd'. Set location of rrd data files. -#####`gr_whitelists_dir` +##### `gr_whitelists_dir` Default is '${gr_storage_dir}/rrd'. Set location of whitelist configuration files. -#####`gr_carbon_conf_dir` +##### `gr_carbon_conf_dir` Default is '${gr_base_dir}/conf'. Set location of Carbon's configuration files. Most relevant when not using pip for installation. A typical location for this may be '/etc/carbon'. -#####`gr_carbon_log_dir` +##### `gr_carbon_log_dir` Default is '${gr_storage_dir}/log/carbon-cache'. Set location of carbon cache log files. -#####`gr_graphiteweb_log_dir` +##### `gr_carbon_log_rotate` + +Default is 'True'. Enable daily log rotation. + +##### `gr_graphiteweb_log_dir` Default is '${gr_storage_dir}/log'. Set location of graphite web log files. -#####`gr_graphiteweb_conf_dir` +##### `gr_graphiteweb_conf_dir` Default is '${gr_base_dir}/conf'. Set location of graphite web configuration. -#####`gr_graphiteweb_webapp_dir` +##### `gr_graphiteweb_webapp_dir` Default is '${gr_base_dir}/webapp'. Set location of graphite web's webapp files. -#####`gr_graphiteweb_storage_dir` +##### `gr_graphiteweb_storage_dir` Default is '/var/lib/graphite-web'. Set location of graphite web's storage, used for graphite.db file. -#####`gr_graphiteweb_install_lib_dir` +##### `gr_graphiteweb_install_lib_dir` Default is '${gr_graphiteweb_webapp_dir}/graphite'. Set location of libraries directory for graphite web. - -#####`gr_storage_schemas` +##### `gr_storage_schemas` Default is ``` @@ -417,7 +440,7 @@ Default is ``` The storage schemas, which describes how long matching graphs are to be stored in detail. -#####`gr_storage_aggregation_rules` +##### `gr_storage_aggregation_rules` Default is the Hashmap: ``` @@ -430,7 +453,7 @@ Default is the Hashmap: ``` The storage aggregation rules. -#####`gr_web_server` +##### `gr_web_server` Default is 'apache'. The web server to configure. Valid values are 'apache', 'nginx', 'wsgionly' or 'none'. @@ -438,62 +461,63 @@ Apache is configured with mod_wsgi, nginx is configured with gunicorn. 'wsgionly The value 'none' means that you will manage the webserver yourself. -#####`gr_web_server_port` +##### `gr_web_server_port` Default is 80. The HTTP port which the web server will use. Only used for $gr_web_server => 'apache' or 'nginx'. -#####`gr_web_server_port_https` +##### `gr_web_server_port_https` Default is 443. The HTTPS port which the web server will use. Only used for $gr_web_server => 'apache'. -#####`gr_web_servername` +##### `gr_web_servername` Default is `$::fqdn` (string). Virtualhostname of Graphite webgui. -#####`gr_web_cors_allow_from_all` +##### `gr_web_cors_allow_from_all` Default is false (boolean). Include CORS Headers for all hosts (*) in web server config. This is needed for tools like Grafana. -#####`gr_use_ssl` +##### `gr_use_ssl` If true, alter web server config to enable SSL. Default is false (boolean). +Only used for apache at the moment. -#####`gr_ssl_cert` +##### `gr_ssl_cert` Path to SSL cert file. Default is undef. -#####`gr_ssl_key` +##### `gr_ssl_key` Path to SSL key file. Default is undef. -#####`gr_ssl_dir` +##### `gr_ssl_dir` Path to SSL dir containing keys and certs. Default is undef. -#####`gr_web_group` +##### `gr_web_group` Group name to chgrp the files that will served by webserver. Only necessary for gr_web_server => 'wsgionly' or 'none'. -#####`gr_web_user` +##### `gr_web_user` Username to chown the files that will served by webserver. Only necessary for gr_web_server => 'wsgionly' or 'none'. -#####`gr_apache_conf_template` +##### `gr_apache_conf_template` Template to use for Apache vhost config. Default is 'graphite/etc/apache2/sites-available/graphite.conf.erb'. -#####`gr_apache_conf_prefix` +##### `gr_apache_conf_prefix` Default is '' (String). Prefix of the Apache config file. Useful if you want to change the order of the virtual hosts to be loaded. For example: '000-' -#####`gr_apache_24` +##### `gr_apache_24` Boolean to enable configuration parts for Apache 2.4 instead of 2.2 Default is false/true (autodected. see params.pp) -#####`gr_apache_noproxy` +##### `gr_apache_noproxy` Optional setting to disable proxying of requests. When set, will supply a value to 'NoProxy'. ``` @@ -507,11 +531,11 @@ Will insert: ``` In the /etc/apache2/conf.d/graphite.conf file. -#####`gr_django_1_4_or_less` +##### `gr_django_1_4_or_less` Default is false (boolean). Django settings style. -#####`gr_django_db_engine` +##### `gr_django_db_engine` Default is 'django.db.backends.sqlite3' (string). Can be set to @@ -521,87 +545,87 @@ Default is 'django.db.backends.sqlite3' (string). Can be set to - django.db.backends.sqlite3 - django.db.backends.oracle -#####`gr_django_db_name` +##### `gr_django_db_name` Default is '/opt/graphite/storage/graphite.db' (string). Name of database to be used by django. -#####`gr_django_db_user` +##### `gr_django_db_user` Default is '' (string). Name of database user. -#####`gr_django_db_password` +##### `gr_django_db_password` Default is '' (string). Password of database user. -#####`gr_django_db_host` +##### `gr_django_db_host` Default is '' (string). Hostname/IP of database server. -#####`gr_django_db_port` +##### `gr_django_db_port` Default is '' (string). Port of database. -#####`gr_enable_carbon_relay` +##### `gr_enable_carbon_relay` Default is false. Enable carbon relay. -#####`gr_relay_line_interface` +##### `gr_relay_line_interface` Default is '0.0.0.0' (string) -#####`gr_relay_line_port` +##### `gr_relay_line_port` Default is 2013 (integer) -#####`gr_relay_enable_udp_listener` +##### `gr_relay_enable_udp_listener` Default is 'False'. Enables the UDP listener for carbon-relay. -#####`gr_relay_udp_receiver_interface` +##### `gr_relay_udp_receiver_interface` Default is '0.0.0.0' (string) -#####`gr_relay_udp_receiver_port` +##### `gr_relay_udp_receiver_port` Default is 2013 (integer) -#####`gr_relay_pickle_interface` +##### `gr_relay_pickle_interface` Default is '0.0.0.0' (string) -#####`gr_relay_pickle_port` +##### `gr_relay_pickle_port` Default is 2014 (integer) -#####`gr_relay_log_listener_connections` +##### `gr_relay_log_listener_connections` Default is 'True' (string). Logs successful connections -#####`gr_relay_method` +##### `gr_relay_method` Default is 'rules' -#####`gr_relay_replication_factor` +##### `gr_relay_replication_factor` Default is 1 (integer). Add redundancy by replicating every datapoint to more than one machine. -#####`gr_relay_diverse_replicas` +##### `gr_relay_diverse_replicas` Default is 'True' (string). Add to guarantee replicas across distributed hosts. -#####`gr_relay_destinations` +##### `gr_relay_destinations` Default is [ '127.0.0.1:2004' ] (array). Array of backend carbons for relay. -#####`gr_relay_max_queue_size` +##### `gr_relay_max_queue_size` Default is 10000 (integer) -#####`gr_relay_use_flow_control` +##### `gr_relay_use_flow_control` Default is 'True' (string). -#####`gr_relay_rules` +##### `gr_relay_rules` Relay rule set. Default is @@ -614,63 +638,63 @@ Default is } ``` -#####`gr_enable_carbon_aggregator` +##### `gr_enable_carbon_aggregator` Default is false (boolean) Enable the carbon aggregator daemon. -#####`gr_aggregator_line_interface` +##### `gr_aggregator_line_interface` Default is '0.0.0.0' (string). Address for line interface to listen on. -#####`gr_aggregator_line_port` +##### `gr_aggregator_line_port` Default is 2023. TCP port for line interface to listen on. -#####`gr_aggregator_enable_udp_listener` +##### `gr_aggregator_enable_udp_listener` Default is 'False' (string). Set this to True to enable the UDP listener. -#####`gr_aggregator_udp_receiver_interface` +##### `gr_aggregator_udp_receiver_interface` Default is '0.0.0.0' (string). Its clear, isnt it? -#####`gr_aggregator_udp_receiver_port` +##### `gr_aggregator_udp_receiver_port` Default is 2023. Self explaining. -#####`gr_aggregator_pickle_interface` +##### `gr_aggregator_pickle_interface` Default is '0.0.0.0' (string). IP address for pickle interface. -#####`gr_aggregator_pickle_port` +##### `gr_aggregator_pickle_port` Default is 2024. Pickle port. -#####`gr_aggregator_log_listener_connections` +##### `gr_aggregator_log_listener_connections` Default is 'True' (string). Logs successful connections -#####`gr_aggregator_forward_all` +##### `gr_aggregator_forward_all` Default is 'True' (string). Forward all metrics to the destination(s) defined in `gr_aggregator_destinations`. -#####`gr_aggregator_destinations` +##### `gr_aggregator_destinations` Default is [ '127.0.0.1:2004' ] (array). Array of backend carbons. -#####`gr_aggregator_max_queue_size` +##### `gr_aggregator_max_queue_size` Default is 10000. Maximum queue size. -#####`gr_aggregator_use_flow_control` +##### `gr_aggregator_use_flow_control` Default is 'True' (string). Enable flow control Can be True or False. -#####`gr_aggregator_max_intervals` +##### `gr_aggregator_max_intervals` Default is 5. Maximum number intervals to keep around. -#####`gr_aggregator_rules` +##### `gr_aggregator_rules` Default is ``` @@ -681,83 +705,83 @@ Default is ``` Hashmap of carbon aggregation rules. -#####`gr_memcache_hosts` +##### `gr_memcache_hosts` Default is undef (array). List of memcache hosts to use. eg ['127.0.0.1:11211','10.10.10.1:11211'] -#####`secret_key` +##### `secret_key` Default is 'UNSAFE_DEFAULT' (string). CHANGE IT! Secret used as salt for things like hashes, cookies, sessions etc. Has to be the same on all nodes of a graphite cluster. -#####`gr_cluster_servers` +##### `gr_cluster_servers` Default is undef (array). Array of webbapp hosts. eg.: ['10.0.2.2:80', '10.0.2.3:80'] -#####`gr_carbonlink_hosts` +##### `gr_carbonlink_hosts` Default is undef (array). Array of carbonlink hosts. eg.: ['10.0.2.2:80', '10.0.2.3:80'] -#####`gr_cluster_fetch_timeout` +##### `gr_cluster_fetch_timeout` Default is 6. Timeout to fetch series data. -#####`gr_cluster_find_timeout` +##### `gr_cluster_find_timeout` Default is 2.5 . Timeout for metric find requests. -#####`gr_cluster_retry_delay` +##### `gr_cluster_retry_delay` Default is 10. Time before retrying a failed remote webapp. -#####`gr_cluster_cache_duration` +##### `gr_cluster_cache_duration` Default is 300. Time to cache remote metric find results. -#####`nginx_htpasswd` +##### `nginx_htpasswd` Default is undef (string). The user and salted SHA-1 (SSHA) password for Nginx authentication. If set, Nginx will be configured to use HTTP Basic authentication with the given user & password. e.g.: 'testuser:$jsfak3.c3Fd0i1k2kel/3sdf3' -#####`nginx_proxy_read_timeout` +##### `nginx_proxy_read_timeout` Default is 10. Value to use for nginx's proxy_read_timeout setting -#####`manage_ca_certificate` +##### `manage_ca_certificate` Default is true (boolean). Used to determine if the module should install ca-certificate on Debian machines during the initial installation. -#####`gr_use_ldap` +##### `gr_use_ldap` Default is false (boolean). Turn ldap authentication on/off. -#####`gr_ldap_uri` +##### `gr_ldap_uri` Default is '' (string). Set ldap uri. -#####`gr_ldap_search_base` +##### `gr_ldap_search_base` Default is '' (string). Set the ldap search base. -#####`gr_ldap_base_user` +##### `gr_ldap_base_user` Default is '' (string).Set ldap base user. -#####`gr_ldap_base_pass` +##### `gr_ldap_base_pass` Default is '' (string). Set ldap password. -#####`gr_ldap_user_query` +##### `gr_ldap_user_query` Default is '(username=%s)' (string). Set ldap user query. -#####`gr_ldap_options` +##### `gr_ldap_options` Hash of additional LDAP options to be enabled. For example, `{ 'ldap.OPT_X_TLS_REQUIRE_CERT' => 'ldap.OPT_X_TLS_ALLOW' }`. Default is `{ }`. -#####`gr_use_remote_user_auth` +##### `gr_use_remote_user_auth` Default is 'False' (string). Allow use of REMOTE_USER env variable within Django/Graphite. -#####`gr_remote_user_header_name` +##### `gr_remote_user_header_name` Default is undef. Allows the use of a custom HTTP header, instead of the REMOTE_USER env variable (mainly for nginx use) to tell Graphite a user is authenticated. Useful when using an external auth handler with X-Accel-Redirect etc. Example value - HTTP_X_REMOTE_USER @@ -767,19 +791,19 @@ combined with the option `gr_web_server` = 'wsgionly' and http://forge.puppetlab with some custom vhosts. The sample external auth app is available from [here](https://github.com/antoinerg/nginx_auth_backend) -#####`gunicorn_arg_timeout` +##### `gunicorn_arg_timeout` Default is 30. value to pass to gunicorns --timeout arg. -#####`gunicorn_bind` +##### `gunicorn_bind` Default is 'unix:/var/run/graphite.sock'. value to pass to gunicorns --bind arg. -#####`gunicorn_workers` +##### `gunicorn_workers` Default is 2. value to pass to gunicorn's --worker arg. -#####`gr_cache_instances` +##### `gr_cache_instances` Default is empty array. Allow multiple additional cache instances. (beside the default one) Example value: @@ -817,105 +841,134 @@ Default is 'False'. Set autoflush for whisper Default is false. Set lock writes for whisper -#####`gr_whisper_fallocate_create` +##### `gr_whisper_fallocate_create` Default is false. Set fallocate_create for whisper -#####`gr_log_cache_performance` +##### `gr_log_cache_performance` Default is 'False' (string). Logs timings for remote calls to carbon-cache -#####`gr_log_rendering_performance` +##### `gr_log_rendering_performance` Default is 'False' (string). Triggers the creation of rendering.log which logs timings for calls to the The Render URL API -#####`gr_log_metric_access` +##### `gr_log_metric_access` Default is 'False' (string). Trigges the creation of metricaccess.log which logs access to Whisper and RRD data files -#####`gr_django_tagging_pkg` +##### `gr_django_tagging_pkg` Default is 'django-tagging' (string) The name of the django-tagging package that should be installed -#####`gr_django_tagging_ver` +##### `gr_django_tagging_ver` Default is '0.3.1' (string) The version of the django-tagging package that should be installed -#####`gr_twisted_pkg` +##### `gr_django_tagging_source` + +Default is `undef` (string). The source of the django-tagging package that should be installed. + +##### `gr_twisted_pkg` Default is 'Twisted' (string) The name of the twisted package that should be installed -#####`gr_twisted_ver` +##### `gr_twisted_ver` Default is '11.1.0' (string) The version of the twisted package that should be installed -#####`gr_txamqp_pkg` +##### `gr_twisted_source` + +Default is `undef` (string). The source of the twisted package that should be installed. + +##### `gr_txamqp_pkg` Default is 'txAMQP' (string) The name of the txamqp package that should be installed -#####`gr_txamqp_ver` +##### `gr_txamqp_ver` Default is '0.4' (string) The version of the txamqp package that should be installed -#####`gr_graphite_pkg` +##### `gr_txamqp_source` + +Default is `undef` (string). The source of the txamqp package that should be installed. + +##### `gr_graphite_pkg` Default is 'graphite-web' (string) The name of the graphite package that should be installed -#####`gr_graphite_ver` +##### `gr_graphite_ver` Default is '0.9.12' (string) The version of the graphite package that should be installed -#####`gr_carbon_pkg` +##### `gr_graphite_source` + +Default is `undef` (string). The source of the graphite package that should be installed. + +##### `gr_carbon_pkg` Default is 'carbon' (string) The name of the carbon package that should be installed -#####`gr_carbon_ver` +##### `gr_carbon_ver` Default is '0.9.12' (string) The version of the carbon package that should be installed -#####`gr_whisper_pkg` +##### `gr_carbon_source` + +Default is `undef` (string). The source of the carbon package that should be installed. + +##### `gr_whisper_pkg` Default is 'whisper' (string) The name of the whisper package that should be installed -#####`gr_whisper_ver` +##### `gr_whisper_ver` Default is '0.9.12' (string) The version of the whisper package that should be installed -#####`gr_django_pkg` +##### `gr_whisper_source` + +Default is `undef` (string). The source of the whisper package that should be installed. + +##### `gr_django_pkg` Default is a platform-specific name of the django package that should be installed (string). -#####`gr_django_ver` +##### `gr_django_ver` Default is 'installed' (string) The version of the django package that should be installed. -#####`gr_django_provider` +##### `gr_django_source` + +Default is `undef` (string). The source of the django package that should be installed. + +##### `gr_django_provider` Default is `undef` (string) The provider of the django package that should be installed. -#####`gr_pip_install` +##### `gr_pip_install` Default is true (Bool). Should packages be installed via pip -#####`gr_disable_webapp_cache` +##### `gr_python_binary` + +Default is 'python' (string). Can be set to a fully-qualify path or an alternative binary name. + +##### `gr_disable_webapp_cache` Default is false (Bool). Should the caching of the webapp be disabled. This helps with some display issues in grafana. -##Requirements +## Requirements -###Modules needed: +### Modules needed: stdlib by puppetlabs -###Software versions needed: - -facter > 1.6.2 -puppet > 2.6.2 +### Software versions needed: On Redhat distributions you need the EPEL or RPMforge repository, because Graphite needs packages, which are not part of the default repos. -##Limitations +## Limitations This module is tested on CentOS 6.5 and Debian 7 (Wheezy) and should also run on @@ -926,7 +979,7 @@ This module is tested on CentOS 6.5 and Debian 7 (Wheezy) and should also run on Most settings of Graphite can be set by parameters. So their can be special configurations for you. In this case you should edit the file `templates/opt/graphite/webapp/graphite/local_settings.py.erb`. -###Compatibility Notes +### Compatibility Notes * There is currently an [open ticket](https://tickets.puppetlabs.com/browse/PUP-3829) with Puppet about broken pip support in CentOS 6/7. The workaround for this bug is to create a symlink from `/usr/bin/pip-python` (which doesn't exist) to `/usr/bin/pip` (which does). * CentOS 7's default `nginx.conf` includes a `server` section listening on port 80. Thus, it is not possible to set up graphite without modifying @@ -934,8 +987,9 @@ the package-provided configuration file. You will have to either manually remove than port 80. * nginx/gunicorn requires a `systemctl restart gunicorn` after installing on Ubuntu 15.10 * SELinux must be disabled +* Installing on Ubuntu 16.04 Xenial requires Puppet 4.1+ (see commit [71251c9](https://github.com/echocat/puppet-graphite/commit/71251c92c8a1b85b7eb1515a009b7808756c7bee)) -##Contributing +## Contributing Echocat modules are open projects. So if you want to make this module even better, you can contribute to this module on [Github](https://github.com/echocat/puppet-graphite). diff --git a/Rakefile b/Rakefile index b2a2b062..211feeb8 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,8 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_class_parameter_defaults') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] +PuppetLint.configuration.send('disable_variable_is_lowercase') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] desc "Validate manifests, templates, and ruby files in lib." task :validate do diff --git a/manifests/config.pp b/manifests/config.pp index 055170e9..77a960b1 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -16,8 +16,7 @@ # python-django-tagging, python-simplejson # optional: python-ldap, python-memcache, memcached, python-sqlite - if ($::osfamily == 'RedHat' and $::operatingsystemrelease =~ /^7\.\d+/) or ( - $::graphite::params::service_provider == 'systemd') { + if ($::osfamily == 'RedHat' and $::operatingsystemrelease =~ /^7\.\d+/) or ($::graphite::gr_service_provider == 'systemd') { $initscript_notify = [Exec['graphite-reload-systemd'],] exec { 'graphite-reload-systemd': @@ -37,7 +36,7 @@ $gr_web_group_REAL = pick($::graphite::gr_web_group, $::graphite::params::apache_web_group) include graphite::config_apache $web_server_package_require = [Package[$::graphite::params::apache_pkg]] - $web_server_service_notify = Service[$::graphite::params::apache_service_name] + $web_server_service_notify = Service[$::graphite::params::apache_service_name] } 'nginx' : { @@ -47,7 +46,7 @@ include graphite::config_gunicorn include graphite::config_nginx $web_server_package_require = [Package['nginx']] - $web_server_service_notify = Service['gunicorn'] + $web_server_service_notify = Service['gunicorn'] } 'wsgionly' : { @@ -64,12 +63,13 @@ 'none' : { # Don't configure apache, gunicorn or nginx. Leave all webserver configuration to something external. if !$::graphite::gr_web_user or !$::graphite::gr_web_group { - fail('Having $gr_web_server => \'none\' requires use of $gr_web_user and $gr_web_group to set correct file owner for your own webserver setup.') + fail('Having $gr_web_server => \'none\' requires use of $gr_web_user and $gr_web_group to set correct file owner for your own webserver setup.' + ) } $gr_web_user_REAL = pick($::graphite::gr_web_user) $gr_web_group_REAL = pick($::graphite::gr_web_group) $web_server_package_require = undef - $web_server_service_notify = undef + $web_server_service_notify = undef } default : { @@ -98,7 +98,7 @@ # first init of user db for graphite exec { 'Initial django db creation': - command => 'python manage.py syncdb --noinput', + command => "${::graphite::gr_python_binary} manage.py syncdb --noinput", cwd => $graphite_web_managepy_location, refreshonly => true, require => $syncdb_require, @@ -106,6 +106,13 @@ } # change access permissions for web server + file { $::graphite::base_dir_REAL: + ensure => directory, + group => $gr_web_group_REAL, + mode => '0755', + owner => $gr_web_user_REAL, + seltype => 'httpd_sys_rw_content_t', + } file { [ $::graphite::storage_dir_REAL, @@ -118,6 +125,7 @@ group => $gr_web_group_REAL, mode => '0755', owner => $gr_web_user_REAL, + seltype => 'httpd_sys_rw_content_t', subscribe => Exec['Initial django db creation'], } @@ -134,24 +142,28 @@ file { $::graphite::local_data_dir_REAL: - ensure => directory, - group => $carbon_group, - mode => '0755', - owner => $carbon_user; + ensure => directory, + group => $carbon_group, + mode => '0755', + seltype => 'httpd_sys_rw_content_t', + owner => $carbon_user; $::graphite::carbon_log_dir_REAL: - ensure => directory, - group => $carbon_group, - mode => '0755', - owner => $carbon_user; + ensure => directory, + group => $carbon_group, + mode => '0755', + seltype => 'httpd_sys_rw_content_t', + owner => $carbon_user; } # Lets ensure graphite.db owner is the same as gr_web_user_REAL file { "${::graphite::storage_dir_REAL}/graphite.db": - ensure => file, - group => $gr_web_group_REAL, - mode => '0644', - owner => $gr_web_user_REAL; + ensure => file, + group => $gr_web_group_REAL, + mode => '0644', + seltype => 'httpd_sys_rw_content_t', + owner => $gr_web_user_REAL, + subscribe => Exec['Initial django db creation'], } # Deploy configfiles @@ -163,6 +175,7 @@ mode => '0644', owner => $gr_web_user_REAL, require => $web_server_package_require, + seltype => 'httpd_sys_content_t', notify => $web_server_service_notify; "${::graphite::graphiteweb_conf_dir_REAL}/graphite_wsgi.py": @@ -172,6 +185,7 @@ mode => '0644', owner => $gr_web_user_REAL, require => $web_server_package_require, + seltype => 'httpd_sys_content_t', notify => $web_server_service_notify; "${::graphite::graphiteweb_install_lib_dir_REAL}/graphite_wsgi.py": @@ -188,6 +202,7 @@ group => $gr_web_group_REAL, mode => '0644', owner => $gr_web_user_REAL, + seltype => 'httpd_sys_rw_content_t', require => $web_server_package_require, } } @@ -219,6 +234,7 @@ content => template('graphite/opt/graphite/conf/relay-rules.conf.erb'), mode => '0644', notify => $notify_services, + seltype => 'httpd_sys_content_t', } } @@ -227,6 +243,7 @@ ensure => file, mode => '0644', content => template('graphite/opt/graphite/conf/aggregation-rules.conf.erb'), + seltype => 'httpd_sys_content_t', notify => $notify_services; } } @@ -236,6 +253,7 @@ ensure => file, content => template('graphite/opt/graphite/conf/storage-schemas.conf.erb'), mode => '0644', + seltype => 'httpd_sys_content_t', notify => $notify_services; $carbon_conf_file: @@ -247,34 +265,38 @@ "${::graphite::carbon_conf_dir_REAL}/storage-aggregation.conf": ensure => file, content => template('graphite/opt/graphite/conf/storage-aggregation.conf.erb'), + seltype => 'httpd_sys_content_t', mode => '0644'; "${::graphite::carbon_conf_dir_REAL}/whitelist.conf": ensure => file, content => template('graphite/opt/graphite/conf/whitelist.conf.erb'), + seltype => 'httpd_sys_content_t', mode => '0644'; "${::graphite::carbon_conf_dir_REAL}/blacklist.conf": ensure => file, content => template('graphite/opt/graphite/conf/blacklist.conf.erb'), + seltype => 'httpd_sys_content_t', mode => '0644'; } # configure logrotate script for carbon - file { "${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh": - ensure => file, - mode => '0544', - content => template('graphite/opt/graphite/bin/carbon-logrotate.sh.erb'), - } + if $::graphite::gr_enable_logrotation { + file { "${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh": + ensure => file, + mode => '0544', + content => template('graphite/opt/graphite/bin/carbon-logrotate.sh.erb'), + } - cron { 'Rotate carbon logs': - command => "${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh", - hour => 3, - minute => 15, - require => File["${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh"], - user => root, + cron { 'Rotate carbon logs': + command => "${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh", + hour => 3, + minute => 15, + require => File["${::graphite::base_dir_REAL}/bin/carbon-logrotate.sh"], + user => root, + } } - # startup carbon engine if $::graphite::gr_enable_carbon_cache { @@ -283,7 +305,7 @@ enable => true, hasrestart => true, hasstatus => true, - provider => $::graphite::params::service_provider, + provider => $::graphite::gr_service_provider, require => File['/etc/init.d/carbon-cache'], } @@ -302,7 +324,7 @@ enable => true, hasrestart => true, hasstatus => true, - provider => $::graphite::params::service_provider, + provider => $::graphite::gr_service_provider, require => File['/etc/init.d/carbon-relay'], } @@ -321,7 +343,7 @@ enable => true, hasrestart => true, hasstatus => true, - provider => $::graphite::params::service_provider, + provider => $::graphite::gr_service_provider, require => File['/etc/init.d/carbon-aggregator'], } diff --git a/manifests/config_apache.pp b/manifests/config_apache.pp index 5a330d2e..7d761234 100644 --- a/manifests/config_apache.pp +++ b/manifests/config_apache.pp @@ -79,7 +79,7 @@ mode => '0755', } exec { 'fix graphite race condition': - command => 'python /tmp/fix-graphite-race-condition.py', + command => "${::graphite::gr_python_binary} /tmp/fix-graphite-race-condition.py", cwd => $graphite::graphiteweb_webapp_dir_REAL, environment => 'DJANGO_SETTINGS_MODULE=graphite.settings', user => $graphite::config::gr_web_user_REAL, @@ -92,6 +92,7 @@ File[$::graphite::storage_dir_REAL], File[$::graphite::graphiteweb_log_dir_REAL], File[$::graphite::graphiteweb_storage_dir_REAL], + File["${::graphite::storage_dir_REAL}/graphite.db"], ], before => Service[$::graphite::params::apache_service_name], subscribe => Exec['Initial django db creation'], diff --git a/manifests/config_gunicorn.pp b/manifests/config_gunicorn.pp index 4e55d1da..033645d9 100644 --- a/manifests/config_gunicorn.pp +++ b/manifests/config_gunicorn.pp @@ -37,7 +37,7 @@ # RedHat package is missing initscript # RedHat 7+ uses systemd - if $::graphite::params::service_provider == 'systemd' { + if $::graphite::gr_service_provider == 'systemd' { file { '/etc/systemd/system/gunicorn.service': ensure => file, @@ -98,7 +98,7 @@ mode => '0755', } exec { 'fix graphite race condition': - command => 'python /tmp/fix-graphite-race-condition.py', + command => "${::graphite::gr_python_binary} /tmp/fix-graphite-race-condition.py", cwd => $graphite::graphiteweb_webapp_dir_REAL, environment => 'DJANGO_SETTINGS_MODULE=graphite.settings', user => $graphite::config::gr_web_user_REAL, @@ -133,7 +133,7 @@ enable => true, hasrestart => true, hasstatus => false, - provider => $::graphite::params::service_provider, + provider => $::graphite::gr_service_provider, require => [ Package[$package_name], File["${::graphite::graphiteweb_conf_dir_REAL}/graphite_wsgi.py"] diff --git a/manifests/config_nginx.pp b/manifests/config_nginx.pp index 541c80a8..b5054eb8 100644 --- a/manifests/config_nginx.pp +++ b/manifests/config_nginx.pp @@ -78,10 +78,10 @@ } } # Finish Debian config - + # Config for RedHat 'RedHat': { - + # Ensure that some directories exist first. This is normally handled by the # package, but if we uninstall and reinstall nginx and delete /etc/nginx. # By default the package manager won't replace the directory. @@ -119,7 +119,7 @@ default: { fail('Only Debian and RedHat-like systems are supported.') } - + } service { diff --git a/manifests/init.pp b/manifests/init.pp index 15467586..43534a6f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,6 +11,10 @@ # The user who runs graphite. If this is empty carbon runs as the user that # invokes it. # Default is empty. +# [*gr_service_provider*] +# Service provider used to start, stop, restart etc. services managed by this +# module. +# Default is debian / redhat / systemd (autodected. see params.pp) # [*gr_enable_carbon_cache*] # Enable carbon cache. # Default is true. @@ -439,42 +443,63 @@ # [*gr_django_tagging_ver*] # String. The version of the django tagging package to install # Default: 0.3.1 +# [*gr_django_tagging_source*] +# String. The source of the django tagging package to install +# Default: undef # [*gr_twisted_pkg*] # String. The name of the twisted package to install # Default: Twisted # [*gr_twisted_ver*] # String. The version of the twisted package to install # Default: 11.1.0 +# [*gr_twisted_source*] +# String. The source of the twisted package to install +# Default: undef # [*gr_txamqp_pkg*] # String. The name of the txamqp package to install # Default: txAMQP # [*gr_txamqp_ver*] # String. The version of the txamqp package to install # Default: 0.4 +# [*gr_txamqp_source*] +# String. The source of the txamqp package to install +# Default: undef # [*gr_graphite_pkg*] # String. The name of the graphite package to install # Default: graphite-web # [*gr_graphite_ver*] # String. The version of the graphite package to install # Default: 0.9.15 +# [*gr_graphite_source*] +# String. The source of the graphite package to install +# Default: undef # [*gr_carbon_pkg*] # String. The name of the carbon package to install # Default: carbon # [*gr_carbon_ver*] # String. The version of the carbon package to install # Default: 0.9.15 +# [*gr_carbon_source*] +# String. The source of the carbon package to install +# Default: undef # [*gr_whisper_pkg*] # String. The name of the whisper package to install # Default: whisper # [*gr_whisper_ver*] # String. The version of the whisper package to install # Default: 0.9.15 +# [*gr_whisper_source*] +# String. The source of the whisper package to install +# Default: undef # [*gr_django_pkg*] -# String. The name of the whisper package to install +# String. The name of the django package to install # Default: whisper # [*gr_django_ver*] -# String. The version of the whisper package to install +# String. The version of the django package to install # Default: 0.9.15 +# [*gr_django_source*] +# String. The source of the django package to install +# Default: undef # [*gr_django_provider*] # String. The provider to use for installing django. # Default: pip @@ -488,6 +513,8 @@ # Boolean. Should the caching of the webapp be disabled. This helps with some # display issues in grafana. # Default: false +# [*gr_enable_logrotation*] +# Boolean. Sets up a cronjob to rotate carbon and webapp logs. # [*gr_apache_port*] # DEPRECATED. Use `gr_web_server_port` now. Trying to set this variable will # cause puppet to fail. @@ -506,6 +533,7 @@ class graphite ( $gr_group = '', $gr_user = '', + $gr_service_provider = $::graphite::params::service_provider, $gr_enable_carbon_cache = true, $gr_max_cache_size = inf, $gr_max_updates_per_second = 500, @@ -678,6 +706,7 @@ $gr_whitelists_dir = undef, $gr_carbon_conf_dir = undef, $gr_carbon_log_dir = undef, + $gr_carbon_log_rotate = 'True', $gr_graphiteweb_log_dir = undef, $gr_graphiteweb_conf_dir = undef, $gr_graphiteweb_webapp_dir = undef, @@ -701,22 +730,31 @@ $wsgi_inactivity_timeout = 120, $gr_django_tagging_pkg = $::graphite::params::django_tagging_pkg, $gr_django_tagging_ver = $::graphite::params::django_tagging_ver, + $gr_django_tagging_source = $::graphite::params::django_tagging_source, $gr_twisted_pkg = $::graphite::params::twisted_pkg, $gr_twisted_ver = $::graphite::params::twisted_ver, + $gr_twisted_source = $::graphite::params::twisted_source, $gr_txamqp_pkg = $::graphite::params::txamqp_pkg, $gr_txamqp_ver = $::graphite::params::txamqp_ver, + $gr_txamqp_source = $::graphite::params::txamqp_source, $gr_graphite_pkg = $::graphite::params::graphite_pkg, $gr_graphite_ver = $::graphite::params::graphite_ver, + $gr_graphite_source = $::graphite::params::graphite_source, $gr_carbon_pkg = $::graphite::params::carbon_pkg, $gr_carbon_ver = $::graphite::params::carbon_ver, + $gr_carbon_source = $::graphite::params::carbon_source, $gr_whisper_pkg = $::graphite::params::whisper_pkg, $gr_whisper_ver = $::graphite::params::whisper_ver, + $gr_whisper_source = $::graphite::params::whisper_source, $gr_django_pkg = $::graphite::params::django_pkg, $gr_django_ver = $::graphite::params::django_ver, + $gr_django_source = $::graphite::params::django_source, $gr_django_provider = $::graphite::params::django_provider, $gr_pip_install = true, $gr_manage_python_packages = true, + $gr_python_binary = $::graphite::params::python_binary, $gr_disable_webapp_cache = false, + $gr_enable_logrotation = true, $gr_carbonlink_query_bulk = undef, $gr_carbonlink_hosts_timeout = '1.0', $gr_rendering_hosts = undef, diff --git a/manifests/install.pp b/manifests/install.pp index 9c8ed424..38cda031 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -13,31 +13,28 @@ } if $::graphite::gr_pip_install and $::osfamily == 'RedHat' { - validate_re($::operatingsystemrelease, '^[6-7]\.\d+', "Unsupported RedHat release: '${::operatingsystemrelease}'") + validate_re($::operatingsystemrelease, '^[6-7]\.\d+|^20\d{2}.\d{2}', "Unsupported RedHat release: '${::operatingsystemrelease}'" + ) } # # Set class variables $gr_pkg_provider = $::graphite::gr_pip_install ? { - default => undef, true => 'pip', + default => undef, } if $::graphite::gr_manage_python_packages { $gr_pkg_require = $::graphite::gr_pip_install ? { - default => undef, true => [ Package[$::graphite::params::graphitepkgs], Package[$::graphite::params::python_pip_pkg], Package[$::graphite::params::python_dev_pkg], ], - } } else { - $gr_pkg_require = $::graphite::gr_pip_install ? { - default => undef, - true => [Package[$::graphite::params::graphitepkgs],], - } } - - $carbon = "carbon-${::graphite::gr_carbon_ver}-py${::graphite::params::pyver}.egg-info" - $gweb = "graphite_web-${::graphite::gr_graphite_ver}-py${::graphite::params::pyver}.egg-info" + default => [Package[$::graphite::params::graphitepkgs]], + } + } else { + $gr_pkg_require = [Package[$::graphite::params::graphitepkgs]] + } # # Manage resources @@ -46,56 +43,71 @@ # python-django-tagging, python-simplejson # optional: python-ldap, python-memcache, memcached, python-sqlite - ensure_packages($::graphite::params::graphitepkgs, { - before => Package['carbon'] - }) + ensure_packages($::graphite::params::graphitepkgs) create_resources('package', { 'carbon' => { - ensure => $::graphite::gr_carbon_ver, - name => $::graphite::gr_carbon_pkg, + ensure => $::graphite::gr_carbon_ver, + name => $::graphite::gr_carbon_pkg, + source => $::graphite::gr_carbon_source, } , 'django-tagging' => { ensure => $::graphite::gr_django_tagging_ver, name => $::graphite::gr_django_tagging_pkg, + source => $::graphite::gr_django_tagging_source, } , 'graphite-web' => { ensure => $::graphite::gr_graphite_ver, name => $::graphite::gr_graphite_pkg, + source => $::graphite::gr_graphite_source, } , 'twisted' => { ensure => $::graphite::gr_twisted_ver, name => $::graphite::gr_twisted_pkg, - before => [ - Package['txamqp'], - Package['carbon'], - ], + source => $::graphite::gr_twisted_source, + before => [Package['txamqp'], Package['carbon'],], } , 'txamqp' => { ensure => $::graphite::gr_txamqp_ver, name => $::graphite::gr_txamqp_pkg, + source => $::graphite::gr_txamqp_source, + before => [ + Package['carbon'], + ], } , 'whisper' => { ensure => $::graphite::gr_whisper_ver, name => $::graphite::gr_whisper_pkg, + source => $::graphite::gr_whisper_source, } , } , { - provider => $gr_pkg_provider, - require => $gr_pkg_require, + provider => $gr_pkg_provider, + require => $gr_pkg_require, + install_options => $gr_pkg_provider ? { + 'pip' => $::graphite::params::pip_install_options, + default => undef, + }, } ) if $::graphite::gr_django_pkg { + $django_install_options = $::graphite::gr_django_provider ? { + 'pip' => $::graphite::params::pip_install_options, + default => undef, + } package { $::graphite::gr_django_pkg: - ensure => $::graphite::gr_django_ver, - provider => $::graphite::gr_django_provider, + ensure => $::graphite::gr_django_ver, + provider => $::graphite::gr_django_provider, + source => $::graphite::gr_django_source, + require => $gr_pkg_require, + install_options => $django_install_options, } } @@ -103,29 +115,26 @@ # using the pip package provider requires python-pip # also install python headers and libs for pip if $::graphite::gr_manage_python_packages { - ensure_packages(flatten([ - $::graphite::params::python_pip_pkg, - $::graphite::params::python_dev_pkg, - ])) + ensure_packages(flatten([$::graphite::params::python_pip_pkg, $::graphite::params::python_dev_pkg,])) } # hack unusual graphite install target - create_resources('file', { + $carbon = "\"carbon-\"*\"-py${::graphite::params::pyver}.egg-info\"" + $gweb = "\"graphite_web-\"*\"-py${::graphite::params::pyver}.egg-info\"" + create_resources('exec', { 'carbon_hack' => { - path => "${::graphite::params::libpath}/${carbon}", - target => "${::graphite::base_dir_REAL}/lib/${carbon}" + command => "ln -s \"${::graphite::base_dir_REAL}/lib/\"${carbon} \"${::graphite::params::libpath}/\"" } , 'gweb_hack' => { - path => "${::graphite::params::libpath}/${gweb}", - target => "${::graphite::base_dir_REAL}/webapp/${gweb}" + command => "ln -s \"${::graphite::base_dir_REAL}/webapp/\"${gweb} \"${::graphite::params::libpath}/\"" } , } , { - ensure => 'link', - require => Package[ - 'carbon', 'graphite-web', 'whisper'], + refreshonly => true, + subscribe => Package['carbon', 'graphite-web', 'whisper'], + provider => 'shell', } ) } diff --git a/manifests/params.pp b/manifests/params.pp index d675b098..7233d22c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,22 +10,29 @@ class graphite::params { $build_dir = '/usr/local/src/' - $python_pip_pkg = 'python-pip' - $django_tagging_pkg = 'django-tagging' - $django_tagging_ver = '0.3.1' - $twisted_pkg = 'Twisted' - $twisted_ver = '11.1.0' - $txamqp_pkg = 'txAMQP' - $txamqp_ver = '0.4' - $graphite_pkg = 'graphite-web' - $graphite_ver = '0.9.15' - $carbon_pkg = 'carbon' - $carbon_ver = '0.9.15' - $whisper_pkg = 'whisper' - $whisper_ver = '0.9.15' - $django_pkg = 'Django' - $django_ver = '1.5' - $django_provider = 'pip' + $django_tagging_pkg = 'django-tagging' + $django_tagging_ver = '0.3.1' + $django_tagging_source = undef + $twisted_pkg = 'Twisted' + $twisted_ver = '11.1.0' + $twisted_source = undef + $txamqp_pkg = 'txAMQP' + $txamqp_ver = '0.4' + $txamqp_source = undef + $graphite_pkg = 'graphite-web' + $graphite_ver = '0.9.15' + $graphite_source = undef + $carbon_pkg = 'carbon' + $carbon_ver = '0.9.15' + $carbon_source = undef + $whisper_pkg = 'whisper' + $whisper_ver = '0.9.15' + $whisper_source = undef + $django_pkg = 'Django' + $django_ver = '1.5' + $django_source = undef + $django_provider = 'pip' + $python_binary = 'python' $install_prefix = '/opt/' @@ -40,6 +47,7 @@ } case $::osfamily { 'Debian': { + $python_pip_pkg = 'python-pip' $apache_dir = '/etc/apache2' $apache_pkg = 'apache2' $apache_service_name = 'apache2' @@ -84,27 +92,36 @@ case $::lsbdistcodename { /squeeze|wheezy|precise/: { - $apache_24 = false - $graphitepkgs = union($common_os_pkgs, ['python-cairo',]) + $apache_24 = false + $graphitepkgs = union($common_os_pkgs, ['python-cairo',]) + $libpath = "/usr/lib/python${pyver}/dist-packages" + $pip_install_options = undef } /jessie|trusty|utopic|vivid|wily/: { - $apache_24 = true - $graphitepkgs = union($common_os_pkgs, ['python-cairo',]) + $apache_24 = true + $graphitepkgs = union($common_os_pkgs, ['python-cairo',]) + $libpath = "/usr/lib/python${pyver}/dist-packages" + $pip_install_options = undef + } + + /xenial/: { + $apache_24 = true + $graphitepkgs = union($common_os_pkgs, ['python-cairo',]) + $libpath = "/usr/local/lib/python${pyver}/dist-packages" + $pip_install_options = [{'--no-binary' => ':all:'}] } default: { fail("Unsupported Debian release: '${::lsbdistcodename}'") } } - $libpath = "/usr/lib/python${pyver}/dist-packages" } 'RedHat': { $apache_dir = '/etc/httpd' $apache_pkg = 'httpd' $apache_service_name = 'httpd' - $apache_wsgi_pkg = 'mod_wsgi' $apache_wsgi_socket_prefix = 'run/wsgi' $apacheconf_dir = '/etc/httpd/conf.d' $apacheports_file = 'graphite_ports.conf' @@ -117,36 +134,61 @@ $nginx_web_group = 'nginx' $nginx_web_user = 'nginx' - $python_dev_pkg = ['python-devel','gcc'] + if $::operatingsystem =~ /^[Aa]mazon$/ { + $_pyver = regsubst($pyver, '\.', '') + $python = "python${_pyver}" + $pyopenssl = "${python}-pyOpenSSL" + $apache_wsgi_pkg = "mod_wsgi-${python}" + $pytz = "${python}-pytz" + $python_pip_pkg = "${python}-pip" + } else { + $python = 'python' + $pyopenssl = 'pyOpenSSL' + $apache_wsgi_pkg = 'mod_wsgi' + $pytz = 'python-tzlocal' + $python_pip_pkg = 'python-pip' + } + + $python_dev_pkg = ["${python}-devel", 'gcc'] $common_os_pkgs = [ - 'MySQL-python', - 'pyOpenSSL', - 'python-ldap', - 'python-memcached', - 'python-psycopg2', - 'python-zope-interface', - 'python-tzlocal', + "MySQL-${python}", + $pyopenssl, + "${python}-ldap", + "${python}-memcached", + "${python}-psycopg2", + "${python}-zope-interface", + $pytz, ] # see https://github.com/graphite-project/carbon/issues/86 case $::operatingsystemrelease { /^6\.\d+$/: { - $apache_24 = false - $graphitepkgs = union($common_os_pkgs,['python-sqlite2', 'bitmap-fonts-compat', 'bitmap', 'pycairo','python-crypto']) - $service_provider = 'redhat' + $apache_24 = false + $graphitepkgs = union($common_os_pkgs,['python-sqlite2', 'bitmap-fonts-compat', 'bitmap', 'pycairo','python-crypto']) + $service_provider = 'redhat' } /^7\.\d+/: { - $apache_24 = true - $graphitepkgs = union($common_os_pkgs,['python-sqlite3dbm', 'dejavu-fonts-common', 'dejavu-sans-fonts', 'python-cairocffi','python2-crypto']) - $service_provider = 'systemd' + $apache_24 = true + $graphitepkgs = union($common_os_pkgs,['python-sqlite3dbm', 'dejavu-fonts-common', 'dejavu-sans-fonts', 'python-cairocffi','python2-crypto']) + $service_provider = 'systemd' + } + + # Amazon Linux 20xx.xx + /^20\d{2}.\d{2}/: { + $apache_24 = false + $graphitepkgs = union($common_os_pkgs,['bitmap', "${python}-pycairo","${python}-crypto"]) + $service_provider = 'redhat' } default: { fail("Unsupported RedHat release: '${::operatingsystemrelease}'") } } + $libpath = "/usr/lib/python${pyver}/site-packages" + + $pip_install_options = undef } default: { diff --git a/metadata.json b/metadata.json index 6150a41d..0e8de115 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "dwerder-graphite", - "version": "6.0.4", + "version": "7.0.0", "source": "https://github.com/echocat/puppet-graphite.git", "author": "Daniel Werdermann", "license": "Apache-2.0", @@ -51,15 +51,20 @@ "operatingsystemrelease": [ "12.04", "14.04", - "15.10" + "15.10", + "16.04" + ] + }, + { + "operatingsystem": "Amazon", + "operatingsystemrelease": [ + "2016.03", + "2015.09", + "2015.03" ] } ], "requirements": [ - { - "name": "pe", - "version_requirement": ">= 3.0.0 < 2015.4.0" - }, { "name": "puppet", "version_requirement": ">= 3.0.0 < 5.0.0" diff --git a/spec/classes/graphite_config_spec.rb b/spec/classes/graphite_config_spec.rb index 5c44d7c2..70c7f7ce 100644 --- a/spec/classes/graphite_config_spec.rb +++ b/spec/classes/graphite_config_spec.rb @@ -32,9 +32,9 @@ shared_context 'RedHat supported platforms' do it { is_expected.to contain_file('/opt/graphite/storage/whisper').with({ - 'ensure' => 'directory', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) } + 'ensure' => 'directory', 'seltype' => 'httpd_sys_rw_content_t', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) } it { is_expected.to contain_file('/opt/graphite/storage/log/carbon-cache').with({ - 'ensure' => 'directory', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) } + 'ensure' => 'directory', 'seltype' => 'httpd_sys_rw_content_t', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) } it { is_expected.to contain_file('/opt/graphite/storage/graphite.db').with({ 'ensure' => 'file', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0644', }) } it { is_expected.to contain_file('/opt/graphite/webapp/graphite/local_settings.py').with({ @@ -42,6 +42,7 @@ 'owner' => 'apache', 'group' => 'apache', 'mode' => '0644', + 'seltype' => 'httpd_sys_content_t', 'content' => /^CONF_DIR = '\/opt\/graphite\/conf'$/, 'notify' => 'Service[httpd]'}).that_requires('Package[httpd]') } it { is_expected.to contain_file('/opt/graphite/conf/graphite_wsgi.py').with({ @@ -50,6 +51,7 @@ 'owner' => 'apache', 'group' => 'apache', 'mode' => '0644', + 'seltype' => 'httpd_sys_content_t', 'notify' => 'Service[httpd]'}).that_requires('Package[httpd]') } it { is_expected.to contain_file('/opt/graphite/webapp/graphite/graphite_wsgi.py').with({ 'ensure' => 'link', @@ -57,7 +59,14 @@ 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]', 'notify' => 'Service[httpd]' }) } - $attributes_redhat = {'ensure' => 'directory', 'group' => 'apache', 'mode' => '0755', 'owner' => 'apache', 'subscribe' => 'Exec[Initial django db creation]'} + it { is_expected.to contain_file('/opt/graphite').with({ + 'ensure' => 'directory', + 'group' => 'apache', + 'mode' => '0755', + 'owner' => 'apache', + 'seltype' => 'httpd_sys_rw_content_t' }) } + + $attributes_redhat = {'ensure' => 'directory', 'seltype' => 'httpd_sys_rw_content_t', 'group' => 'apache', 'mode' => '0755', 'owner' => 'apache', 'subscribe' => 'Exec[Initial django db creation]'} ['/opt/graphite/storage', '/opt/graphite/storage/rrd', '/opt/graphite/storage/lists', @@ -128,7 +137,14 @@ 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]', 'notify' => 'Service[apache2]'}) } - $attributes_debian = {'ensure' => 'directory', 'group' => 'www-data', 'mode' => '0755', 'owner' => 'www-data', 'subscribe' => 'Exec[Initial django db creation]'} + it { is_expected.to contain_file('/opt/graphite').with({ + 'ensure' => 'directory', + 'group' => 'www-data', + 'mode' => '0755', + 'owner' => 'www-data', + 'seltype' => 'httpd_sys_rw_content_t' }) } + + $attributes_debian = {'ensure' => 'directory', 'seltype' => 'httpd_sys_rw_content_t', 'group' => 'www-data', 'mode' => '0755', 'owner' => 'www-data', 'subscribe' => 'Exec[Initial django db creation]'} ['/opt/graphite/storage', '/opt/graphite/storage/rrd', '/opt/graphite/storage/lists', @@ -136,6 +152,7 @@ '/var/lib/graphite-web'].each { |f| it { is_expected.to contain_file(f).with($attributes_debian)} } + end shared_context 'Debian sysv platforms' do @@ -193,7 +210,7 @@ case facts[:lsbdistcodename] when /squeeze|wheezy|precise|trusty|utopic|vivid/ then it_behaves_like 'Debian sysv platforms' - when /jessie|wily/ then + when /jessie|wily|xenial/ then it_behaves_like 'Debian systemd platforms' else it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )} diff --git a/spec/classes/graphite_install_spec.rb b/spec/classes/graphite_install_spec.rb index fab0430a..17ff1350 100644 --- a/spec/classes/graphite_install_spec.rb +++ b/spec/classes/graphite_install_spec.rb @@ -4,8 +4,9 @@ # Convenience variable for 'hack' file checks hack_defaults = { - :ensure => 'link', - :require => ['Package[carbon]','Package[graphite-web]','Package[whisper]'], + :refreshonly => true, + :provider => 'shell', + :subscribe => ['Package[carbon]','Package[graphite-web]','Package[whisper]'], } shared_context 'supported platforms' do @@ -20,8 +21,8 @@ 'Package[python-ldap]').that_requires( 'Package[python-psycopg2]') } end - it { is_expected.to contain_file('carbon_hack').with(hack_defaults) } - it { is_expected.to contain_file('gweb_hack').with(hack_defaults) } + it { is_expected.to contain_exec('carbon_hack').with(hack_defaults) } + it { is_expected.to contain_exec('gweb_hack').with(hack_defaults) } end shared_context 'no pip' do @@ -33,8 +34,8 @@ it { is_expected.not_to contain_package('python-pip') } it { is_expected.not_to contain_package('python-dev') } it { is_expected.not_to contain_package('python-devel') } - it { is_expected.not_to contain_file('carbon_hack') } - it { is_expected.not_to contain_file('gweb_hack') } + it { is_expected.not_to contain_exec('carbon_hack') } + it { is_expected.not_to contain_exec('gweb_hack') } end shared_context 'no django' do @@ -64,13 +65,11 @@ it { is_expected.to contain_package('bitmap-fonts-compat').with_provider(nil) } it { is_expected.to contain_package('python-crypto').with_provider(nil) } - it { is_expected.to contain_file('carbon_hack').only_with(hack_defaults.merge({ - :target => '/opt/graphite/lib/carbon-0.9.15-py2.6.egg-info', - :path => '/usr/lib/python2.6/site-packages/carbon-0.9.15-py2.6.egg-info', + it { is_expected.to contain_exec('carbon_hack').only_with(hack_defaults.merge({ + :command => 'ln -s "/opt/graphite/lib/""carbon-"*"-py2.6.egg-info" "/usr/lib/python2.6/site-packages/"', })) } - it { should contain_file('gweb_hack').only_with(hack_defaults.merge({ - :target => '/opt/graphite/webapp/graphite_web-0.9.15-py2.6.egg-info', - :path => '/usr/lib/python2.6/site-packages/graphite_web-0.9.15-py2.6.egg-info', + it { should contain_exec('gweb_hack').only_with(hack_defaults.merge({ + :command => 'ln -s "/opt/graphite/webapp/""graphite_web-"*"-py2.6.egg-info" "/usr/lib/python2.6/site-packages/"', })) } end @@ -82,13 +81,11 @@ it { is_expected.to contain_package('dejavu-sans-fonts').with_provider(nil) } it { is_expected.to contain_package('python2-crypto').with_provider(nil) } - it { is_expected.to contain_file('carbon_hack').only_with(hack_defaults.merge({ - :target => '/opt/graphite/lib/carbon-0.9.15-py2.7.egg-info', - :path => '/usr/lib/python2.7/site-packages/carbon-0.9.15-py2.7.egg-info', + it { is_expected.to contain_exec('carbon_hack').only_with(hack_defaults.merge({ + :command => 'ln -s "/opt/graphite/lib/""carbon-"*"-py2.7.egg-info" "/usr/lib/python2.7/site-packages/"', })) } - it { is_expected.to contain_file('gweb_hack').only_with(hack_defaults.merge({ - :target => '/opt/graphite/webapp/graphite_web-0.9.15-py2.7.egg-info', - :path => '/usr/lib/python2.7/site-packages/graphite_web-0.9.15-py2.7.egg-info', + it { is_expected.to contain_exec('gweb_hack').only_with(hack_defaults.merge({ + :command => 'ln -s "/opt/graphite/webapp/""graphite_web-"*"-py2.7.egg-info" "/usr/lib/python2.7/site-packages/"', })) } end @@ -112,8 +109,8 @@ let(:facts) do facts end - let :pre_condition do - 'include ::graphite' + let :pre_condition do + 'include ::graphite' end case facts[:osfamily] diff --git a/templates/etc/init.d/Debian/carbon-aggregator.erb b/templates/etc/init.d/Debian/carbon-aggregator.erb index 12e7c180..61c13c5c 100644 --- a/templates/etc/init.d/Debian/carbon-aggregator.erb +++ b/templates/etc/init.d/Debian/carbon-aggregator.erb @@ -12,7 +12,7 @@ # Description: Enables Graphites carbon-aggregator data aggregation engine ### END INIT INFO -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="aggregator" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" STOP_COUNTER=12 # 12 times 5s -> 60 secs diff --git a/templates/etc/init.d/Debian/carbon-cache.erb b/templates/etc/init.d/Debian/carbon-cache.erb index ca3f86f3..754f00ab 100644 --- a/templates/etc/init.d/Debian/carbon-cache.erb +++ b/templates/etc/init.d/Debian/carbon-cache.erb @@ -12,7 +12,7 @@ # Description: Enables Graphites carbon-cache data cache engine ### END INIT INFO -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="cache" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" STOP_COUNTER=12 # 12 times 5s -> 60 secs diff --git a/templates/etc/init.d/Debian/carbon-relay.erb b/templates/etc/init.d/Debian/carbon-relay.erb index b81fec70..ea67ef48 100644 --- a/templates/etc/init.d/Debian/carbon-relay.erb +++ b/templates/etc/init.d/Debian/carbon-relay.erb @@ -12,7 +12,7 @@ # Description: Enables Graphites carbon-relay ### END INIT INFO -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="relay" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" STOP_COUNTER=12 # 12 times 5s -> 60 secs @@ -31,8 +31,8 @@ case "${OPERATION}" in if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - <% if @gr_carbon_relay_ulimit -%> - ulimit -n <%= @gr_carbon_relay_ulimit %> + <% if scope.lookupvar('graphite::gr_carbon_relay_ulimit') -%> + ulimit -n <%= scope.lookupvar('graphite::gr_carbon_relay_ulimit') %> <% end -%> ${PYTHON_CMD} ${GRAPHITE_DIR}/bin/carbon-${CARBON_DAEMON}.py --instance=${INSTANCE} start done diff --git a/templates/etc/init.d/RedHat/carbon-aggregator.erb b/templates/etc/init.d/RedHat/carbon-aggregator.erb index aeb8f49f..e135751f 100644 --- a/templates/etc/init.d/RedHat/carbon-aggregator.erb +++ b/templates/etc/init.d/RedHat/carbon-aggregator.erb @@ -19,7 +19,7 @@ # Source function library. . /etc/rc.d/init.d/functions -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="aggregator" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" diff --git a/templates/etc/init.d/RedHat/carbon-cache.erb b/templates/etc/init.d/RedHat/carbon-cache.erb index 9176942a..0cd2ea5f 100644 --- a/templates/etc/init.d/RedHat/carbon-cache.erb +++ b/templates/etc/init.d/RedHat/carbon-cache.erb @@ -19,7 +19,7 @@ # Source function library. . /etc/rc.d/init.d/functions -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="cache" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" diff --git a/templates/etc/init.d/RedHat/carbon-relay.erb b/templates/etc/init.d/RedHat/carbon-relay.erb index 7a978efb..58a912b0 100644 --- a/templates/etc/init.d/RedHat/carbon-relay.erb +++ b/templates/etc/init.d/RedHat/carbon-relay.erb @@ -19,7 +19,7 @@ # Source function library. . /etc/rc.d/init.d/functions -PYTHON_CMD='python -W ignore' +PYTHON_CMD='<%= scope.lookupvar('graphite::gr_python_binary') %> -W ignore' CARBON_DAEMON="relay" GRAPHITE_DIR="<%= scope.lookupvar('graphite::base_dir_REAL') %>" PIDFILE_DIR="<%= scope.lookupvar('graphite::storage_dir_REAL') %>" @@ -38,8 +38,8 @@ start() if [ "${INSTANCE}" = "${CARBON_DAEMON}" ]; then INSTANCE="a"; fi; - <% if @gr_carbon_relay_ulimit -%> - ulimit -n <%= @gr_carbon_relay_ulimit %> + <% if scope.lookupvar('graphite::gr_carbon_relay_ulimit') -%> + ulimit -n <%= scope.lookupvar('graphite::gr_carbon_relay_ulimit') %> <% end -%> pidfile=${PIDFILE_DIR}/carbon-${CARBON_DAEMON}-${INSTANCE}.pid prog=carbon-${CARBON_DAEMON}-${INSTANCE} diff --git a/templates/etc/nginx/sites-available/graphite.erb b/templates/etc/nginx/sites-available/graphite.erb index 3b74d0f8..ec13b40d 100644 --- a/templates/etc/nginx/sites-available/graphite.erb +++ b/templates/etc/nginx/sites-available/graphite.erb @@ -33,7 +33,7 @@ server { proxy_connect_timeout 10; proxy_read_timeout <%= scope.lookupvar('graphite::nginx_proxy_read_timeout') %>; - proxy_pass http://<%= scope.lookupvar('graphite::gunicorn_bind') %>:/; + proxy_pass http://<%= scope.lookupvar('graphite::gunicorn_bind') %>; <% if scope.lookupvar('graphite::gr_web_cors_allow_from_all') %> add_header Access-Control-Allow-Origin "*"; diff --git a/templates/opt/graphite/conf/carbon.conf.erb b/templates/opt/graphite/conf/carbon.conf.erb index f95d35ca..9ab5afeb 100644 --- a/templates/opt/graphite/conf/carbon.conf.erb +++ b/templates/opt/graphite/conf/carbon.conf.erb @@ -332,7 +332,7 @@ CARBON_METRIC_INTERVAL = <%= scope.lookupvar('graphite::gr_carbon_metric_interva [aggregator] # Enable daily log rotation. If disabled, a kill -HUP can be used after a manual rotate -ENABLE_LOGROTATION = True +ENABLE_LOGROTATION = <%= scope.lookupvar('graphite::gr_carbon_log_rotate') %> # Specify the user to drop privileges to # If this is blank carbon runs as the user that invokes it diff --git a/templates/opt/graphite/webapp/graphite/local_settings.py.erb b/templates/opt/graphite/webapp/graphite/local_settings.py.erb index b9b4ec1c..3476ff8b 100644 --- a/templates/opt/graphite/webapp/graphite/local_settings.py.erb +++ b/templates/opt/graphite/webapp/graphite/local_settings.py.erb @@ -90,7 +90,20 @@ CONTENT_DIR = '<%= scope.lookupvar('graphite::graphiteweb_webapp_dir_REAL') %>/c # NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing WHISPER_DIR = '<%= scope.lookupvar('graphite::local_data_dir_REAL') %>' RRD_DIR = '<%= scope.lookupvar('graphite::rrd_dir_REAL') %>' -#DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables +<% + if scope.lookupvar('graphite::gr_cache_instances') + cache_instances = scope.lookupvar('graphite::gr_cache_instances') + end + whisper_dirs = Array.new + #if cache_instances != nil + cache_instances.each do |name, params| + if params["LOCAL_DATA_DIR"] then + whisper_dirs << params["LOCAL_DATA_DIR"] + end + end + unless whisper_dirs.empty? %> +DATA_DIRS = [WHISPER_DIR, RRD_DIR,<%= whisper_dirs.map{|s| "'#{s}'" }.join(',') %>] # Default: set from the above variables +<% end -%> LOG_DIR = '<%= scope.lookupvar('graphite::graphiteweb_log_dir_REAL') %>' #INDEX_FILE = '/opt/graphite/storage/index' # Search index file