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

Select Status

RSS

haproxy2 (1) Versions 0.5.7

Installs and configures haproxy

Policyfile
Berkshelf
Knife
cookbook 'haproxy2', '~> 0.5.7', :supermarket
cookbook 'haproxy2', '~> 0.5.7'
knife supermarket install haproxy2
knife supermarket download haproxy2
README
Dependencies
Quality 17%

Description

Installs and configures HAproxy

Requirements

Chef

Tested on 0.10.8 but newer and older version should work just fine.

Platform

The following platforms have been tested with this cookbook, meaning that the
recipes run on these platforms without error:

  • ubuntu
  • debian

Cookbooks

There are no external cookbook dependencies.

Installation

Just place the haproxy2 directory in your chef cookbook directory and
upload it to your Chef server.

Usage

Simply include recipe[haproxy2] in your run_list.

This cookbook does not have a template to create the haproxy.cfg file,
this file is generated dinamically depending of the pairs of keys and values
of the attributes.

The global and the defaults sections, the listens, the frontends and the
backends follow the same rules regarding how the cookbook will generate
the configuration file. The idea is generate the config file setting attributes
in the node, or trhough roles avoiding the templates.

The global and defaults sections are hashes with which their pair of keys and
values are the settings that will applied on them.

The listens, frontends and the backends are an array of hashes, where each
pair of keys and values of each hash are the settings that will be applied
for them. They have three special attributes (name, role_app and
member_options) that will not be considered settings of the listen,
frontend or the backend but they are used for:

  • name: defines the name of the listen, frontend or backend
  • role_app: defines the role with which the nodes will be searched in order to use their info to set the servers options.
  • member_options: It is a hash that could contain the keys port (it is the port that will be used in the server option) and extra (you can set the extra options for the server option).

Regarding the values of the attributes, if you need to set a parameter
without values, you need to set this value to true, but if you need to set
a value you need to set a string. If it is false, the parameter will be not
set. If it is an array, the parameter will be set with the elements of the
array individually.

There is three special keywords (IPADDRESS, HOSTNAME, FQDN) that will be
replaced by the corresponding attribute of the node.

For example, the following settings:

"haproxy" => {
  "global" => {
    "log" => "/dev/log local0 notice",
    "maxconn" => 4096,
    "debug" => false,
    "quiet" => true,
    "user" => "haproxy",
    "group" => "haproxy"
  },
  "defaults" => {
    "log" => "global",
    "mode" => "http",
    "option" => [ "httplog", "dontlognull", "redispatch" ],
    "retries" =>  3,
    "maxconn" => 2000,
    "contimeout" => 5000,
    "clitimeout" => 50000,
    "srvtimeout" => 50000
  },
  "listen" => [
    {
      "name" => "load_balancer",
      "role_app" => lb_nodes",
      "member_options" => {
        "port" => "1060",
        "extra" => "check"
      },
      "bind" => "IPADDRESS:80",
      "maxconn" => "500000",
      "balance" => "url_param jid",
      "option" => ["httpclose", "redispatch", "forwardfor"]
    },
    {
      "name" => "health_check",
      "bind" => "127.0.0.1:60000",
      "mode" => "health"
    },
    {
      "name" => "stats",
      "bind" => "10.10.10.10:80",
      "maxconn" => "10",
      "mode" => "http",
      "stats" => [
        "enable",
        "hide-version",
        "realm Haproxy",
        "uri /proxy?stats",
        "auth status:pass123"
      ]
    },
    {
      "name" => "admin",
      "bind" => "0.0.0.0:22002",
      "mode" => "http",
      "stats" => "uri /"
    }
  ]
}

Will generate the following configuration file (the ip address of the node will be 40.51.127.1):

global
       group haproxy
       log /dev/log local0 notice
       maxconn 4096
       user haproxy
       quiet

defaults
       clitimeout 50000
       contimeout 5000
       log global
       maxconn 2000
       mode http
       option httplog
       option dontlognull
       option redispatch
       retries 3
       srvtimeout 50000

listen load_balancer
       balance url_param jid
       bind 40.51.127.1:80
       maxconn 500000
       option httpclose
       option redispatch
       option forwardfor
       server node00 10.0.0.100:1060 check
       server node01 10.0.0.101:1060 check
       server node02 10.0.0.102:1060 check
       server node03 10.0.0.103:1060 check

listen health_check
       bind 127.0.0.1:60000
       mode health

listen stats
       bind 10.10.10.10:80
       maxconn 10
       mode http
       stats enable
       stats hide-version
       stats realm Haproxy
       stats uri /proxy?stats
       stats auth status:pass123

listen admin
       bind 0.0.0.0:22002
       mode http
       stats uri /

(The servers option of the load_balancer listen were added automatically. The cookbook search
the nodes that have the role lb_nodes in their runlist and added them to the listen settings)

Recipes

default

This recipe installs, configures and starts the haproxy service.

Attributes

node['haproxy']['daemon']['enable']

If it true, set ENABLE=1 in the /etc/default/haproxy file.

node['haproxy']['daemon']['extra_options']

It set the extra options which will be started the haproxy daemon.

node['haproxy']['global']

Hash that contains the options and the values of the global section.

node['haproxy']['defaults']

Hash that contains the options and the values of the defaults section.

node['haproxy']['frontend']

Array of the hashes. Each hash contain the options and the values of a
frontend definition.

node['haproxy']['backend']

Array of the hashes. Each hash contain the options and the values of a
backend definition.

node['haproxy']['listen']

Array of the hashes. Each hash contain the options and the values of a
listen definition.

Resources and Providers

There are none defined.

Libraries

There are none defined.

Development

Pull requests are very welcome! Make sure your patches are well tested.
Ideally create a topic branch for every separate change you make.

License and Author

Author:: Claudio Cesar Sanchez Tejeda demonccc@gmail.com

Copyright:: 2012, Claudio Cesar Sanchez Tejeda

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Collaborator Number Metric
            

0.5.7 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

0.5.7 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

0.5.7 failed this metric

FC064: Ensure issues_url is set in metadata: haproxy2/metadata.rb:1
FC065: Ensure source_url is set in metadata: haproxy2/metadata.rb:1
FC066: Ensure chef_version is set in metadata: haproxy2/metadata.rb:1
FC069: Ensure standardized license defined in metadata: haproxy2/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

0.5.7 passed this metric

Testing File Metric
            

0.5.7 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

0.5.7 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number