cookbook 'squaresurf_influxdb', '= 1.0.0', :supermarket
squaresurf_influxdb (7) Versions 1.0.0 Follow1
cookbook 'squaresurf_influxdb', '= 1.0.0'
knife cookbook site install squaresurf_influxdb
knife cookbook site download squaresurf_influxdb
SquareSurf InfluxDB Cookbook
Chef cookbook for installing and configuring InfluxDB. This cookbook took inspiration from the influxdb cookbook. The main difference is that this cookbook tries to take the approach that InfluxDB should be always running once it is installed. Whereas my understanding of the influxdb cookbook is that it tries to seperate configuration from starting the service into two processes.
- Chef version 0.11 or higher
- Ruby 1.9 (preferably from the Chef full-stack installer)
- Ubuntu 14.04
Note: I'm open to more platforms, this is just what I started with in order to fill my current need.
Use the squaresurf_influxdb_user resource to create/update/delete an InfluxDB database user.
username- Name for the user. (Defaults to the name of the block)
password- Password for the user.
database- The database the user will have access to.
admin- A bool whether or not the user is a database admin. (default: false)
read_from- A regex to match the series the user can read from. (default: '.*')
write_to- A regex to match the series the user can write to. (default: '.*')
Create a user
squaresurf_influxdb_user 'john' do action :create password 'super secret' database 'metrics' admin true read_from '/^public$/' write_to '/^john_workspace$/' end
Delete a user
squaresurf_infludb_user 'old_user' do action :delete database 'sensitive data' end
Use the squaresurf_influxdb_cluster_admin resource to create/update/delete an InfluxDB cluster admin.
username- Name for the cluster admin. (Defaults to the name of the block)
password- Password for the cluster admin.
Create a cluster admin
squaresurf_influxdb_cluster_admin 'jane' do action :create password 'super secret again' end
Delete a cluster admin
squaresurf_infludb_cluster_admin 'old_cluster_admin' do action :delete end
Use the squaresurf_influxdb_database resource to create/update/delete an InfluxDB database.
database- Database name. (Defaults to the name of the block)
Create a database
Delete a database
squaresurf_infludb_database 'old_project_name' do action :delete end
This recipe includes the squaresurf_influxdb::install recipe then the squaresurf_influxdb::configure recipe.
This recipe will download the appropriate package according to the version attribute and install it.
This recipe will: * Setup the influxdb service to be enabled and start. * Write out to toml the config and benchmark_config from the node attributes. * Update the main cluster admin password if it has changed. * Create an alternate cluster admin user if the main admin username is different than root * Delete the root user if the main cluster admin username is different than root
This is used by our chef spec and kitchen test suites.
This is used by our chef spec test suite.
Attributes that will affect general cookbook usage.
default.squaresurf_influxdb.fail_on_error = true
If set to false then failures will not fail the chef run and will log errors instead.
Attributes that affect the installation of InfluxDB.
default.squaresurf_influxdb.version = :latest
This will decide which version of InfluxDB to download and install. It can
either be the version string or the ruby symbol
:latest in order to install
the latest available.
default.squaresurf_influxdb.update_version = false
This will decide whether or not to install a new version of influxdb if it is already installed and the version attribute above differs from that of the installed version.
InfluxDB Client Attributes
Attributes that affect the ability for this cookbook to connect to InfluxDB in order to configure users, cluster admins, and databases.
default.squaresurf_influxdb.client_retries = 10
This is how many times we should try to connect to InfluxDB before giving up. Set this to nil or '-1' to retry indefinitely.
default.squaresurf_influxdb.client_hosts = ['localhost']
This is the host we should connect to InfluxDB with.
default.squaresurf_influxdb.client_use_ssl = false
Whether or not we should connect via ssl with our client when configuring users, cluster admins, and databases.
default.squaresurf_influxdb.admin_username = 'root'
The cluster admin username to use when connecting to InfluxDB.
default.squaresurf_influxdb.admin_password = 'root'
The cluster admin password to use when connecting to InfluxDB.
default.squaresurf_influxdb.admin_old_username = 'root'
The previous cluster admin username for use if you ever change the username to another value. This is so that we can create a new cluster admin and delete this old cluster admin.
default.squaresurf_influxdb.admin_old_password = 'root'
The previous cluster admin password for use if you ever change the password to another value. This is so that we can set the new password.
InfluxDB TOML Config Attributes
This should be a ruby hash that will be converted to toml for the InfluxDB config.toml. The default was generated from the default config.toml that comes with InfluxDB.
This should be a ruby hash that will be converted to toml for the InfluxDB benchmark_config.toml. The default was generated from the default benchmark_config.toml that comes with InfluxDB.
The one main attribute that you should always change is the node.squaresurf_influxdb.admin_password. That way you won't have a default cluster admin password that anyone can connect to your server with.
Either include the recipe in your run_list or
include_recipe from within
one of your recipes. For example you could do the following to setup influxdb
and create a database named metrics and a user named sensu.
# Make sure to set the admin password to some secret value. It would probably # be even better to use an encrypted data bag here as shown in the next example. node.set.squaresurf_influxdb.admin_password = 'super secret' include_recipe 'squaresurf_influxdb::default' squaresurf_influxdb_database 'metrics' squaresurf_influxdb_user 'sensu' do password 'some secret value' database 'metrics' end
squaresurf_influxdb::install and squaresurf_influxdb::configure
Instead of using the default recipe you can seperate your logic into an install then a configure in case you need to setup some items vefore the service is started. For example you could set up ssl configuration for the http api like so:
cert_file = '/opt/influxdb/ssl_cert.pem' node.set.squaresurf_influxdb.config.api['ssl-cert'] = cert_file node.set.squaresurf_influxdb.config.api['ssl-port'] = 8084 cert = Chef::EncryptedDataBagItem.load('ssl', 'influxdb') admin = Chef::EncryptedDataBagItem.load('influxdb', 'admin') node.default.squaresurf_influxdb.admin_password = admin['password'] node.default.squaresurf_influxdb.admin_old_password = admin['old_password'] # install first so that the /opt/influxdb dir and influxdb user will be created include_recipe 'squaresurf_influxdb::install' file cert_file do content cert['cert'] + "\n" + cert['key'] user 'influxdb' group 'influxdb' mode '0700' end include_recipe 'squaresurf_influxdb::configure'
- Fork the repository on Github
- Create a named feature branch (like
- Write your change
- Write tests for your change
- Run the tests, ensuring they all pass
- Submit a Pull Request using Github
There is a Rakefile with tasks to make testing easy. You will probably need to
bundle install before running any of them.
- rake test:all # Run all tests
- rake test:chefspec # Run chefspec
- rake test:foodcritic # Run foodcritic linter against cookbook
- rake test:kitchen_test # This is here as a convenience so that the test suite will check kitchen as well as the other tests
- rake test:rubocop # Run rubocop against cookbook ruby files
config and benchmark_config attribute generation
There is a convenience script
toml_to_attr.rb to help generate the config and
benchmark_config ruby hashes from a default toml file included with influxdb.
If you haven't run
bundle install for the test suite above you'll probably
need to do so in order to run
License and Authors
The License is the MIT License and can be found in the LICENSE file.
This cookbook has no specified dependencies.
There are no cookbooks that are contingent upon this one.
This file is used to list changes made in each version of the squaresurf_influxdb cookbook.
- [squaresurf] Updates the default config attributes for InfluxDB version 0.8.6.
- [squaresurf] Updates the configure recipe to be more efficient and ensures that the config files have the correct user and group.
- [squaresurf] Simplifies the SquaresurfInfluxDB::ClusterAdmin.client.
- [squaresurf] Removes unnecessary files.
- [squaresurf] Adds documentation about the client_retries attribute.
- [squaresurf] Fixes issue where we incorrectly get a cluster admin client.
- [squaresurf] Ensure that we don't incorrectly delete the root cluster admin.
- [squaresurf] Up the number of default client retries to 20.
- [squaresurf] Adds supported platform to the metadata.
- [squaresurf] Fix typos in README.md.
- [squaresurf] Initial version for the squaresurf_influxdb cookbook.
1.0.0 passed this metric
1.0.0 passed this metric