Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

RSS

squaresurf_influxdb (7) Versions 1.0.0

Installs/Configures squaresurf_influxdb

Berkshelf/Librarian
Policyfile
Knife
cookbook 'squaresurf_influxdb', '= 1.0.0'
cookbook 'squaresurf_influxdb', '= 1.0.0', :supermarket
knife cookbook site install squaresurf_influxdb
knife cookbook site download squaresurf_influxdb
README
Dependencies
Changelog
Quality

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.

Requirements

  • Chef version 0.11 or higher
  • Ruby 1.9 (preferably from the Chef full-stack installer)

Tested Platforms

  • Ubuntu 14.04

Note: I'm open to more platforms, this is just what I started with in order to fill my current need.

Resources

squaresurf_influxdb_user

Use the squaresurf_influxdb_user resource to create/update/delete an InfluxDB database user.

Actions

  • :create (Default)
  • :delete

Attributes

  • 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: '.*')

Examples

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

squaresurf_influxdb_cluster_admin

Use the squaresurf_influxdb_cluster_admin resource to create/update/delete an InfluxDB cluster admin.

Actions

  • :create (Default)
  • :delete

Attributes

  • username - Name for the cluster admin. (Defaults to the name of the block)
  • password - Password for the cluster admin.

Examples

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

squaresurf_influxdb_database

Use the squaresurf_influxdb_database resource to create/update/delete an InfluxDB database.

Actions

  • :create (Default)
  • :delete

Attributes

  • database - Database name. (Defaults to the name of the block)

Examples

Create a database
squaresurf_influxdb_database 'metrics'
Delete a database
squaresurf_infludb_database 'old_project_name' do
  action :delete
end

Recipes

squaresurf_influxdb::default

This recipe includes the squaresurf_influxdb::install recipe then the squaresurf_influxdb::configure recipe.

squaresurf_influxdb::install

This recipe will download the appropriate package according to the version attribute and install it.

squaresurf_influxdb::configure

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

squaresurf_influxdb::test

This is used by our chef spec and kitchen test suites.

squaresurf_influxdb::test_exceptions

This is used by our chef spec test suite.

Attributes

General Attributes

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.

Install attributes

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

default.squaresurf_influxdb.config

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.

default.squaresurf_influxdb.benchmark_config

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.

Usage

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.

squaresurf_influxdb::default

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'

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

Testing

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 toml_to_attr.rb.

License and Authors

License

The License is the MIT License and can be found in the LICENSE file.

Authors

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

squaresurf_influxdb CHANGELOG

This file is used to list changes made in each version of the squaresurf_influxdb cookbook.

v1.0.0

  • [squaresurf] Updates the default config attributes for InfluxDB version 0.8.6.

v0.1.4

  • [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.

v0.1.3

  • [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.

v0.1.2

  • [squaresurf] Adds supported platform to the metadata.

v0.1.1

  • [squaresurf] Fix typos in README.md.

v0.1.0

  • [squaresurf] Initial version for the squaresurf_influxdb cookbook.

Foodcritic Metric
            

1.0.0 passed this metric