Skip to content
Browse files

add attributes for haproxy for better customization

  • Loading branch information...
1 parent cd56af9 commit dea88e3b46cded5e23384ee7abc63fb861e42813 @jtimberman jtimberman committed
View
18 haproxy/README.rdoc
@@ -6,19 +6,21 @@ Installs haproxy and prepares the configuration location.
== Platform:
-Tested on Ubuntu 8.10.
+Tested on Ubuntu 8.10 and higher.
== Cookbooks:
-= ATTRIBUTES:
+= ATTRIBUTES:
-No haproxy-specific attributes are used in the default recipe.
-
-The app_lb recipe can search for a user defined role name to load balance.
+* `node['haproxy']['member_port']` - the port that member systems will be listening on, default 80
+* `node['haproxy']['enable_admin']` - whether to enable the admin interface. default true. Listens on port 22002.
+* `node['haproxy']['app_server_role']` - used by the `app_lb` recipe to search for a specific role of member systems. Default `webserver`.
= USAGE:
-For the default recipe, update the haproxy.cfg file with listener(s) for your sites/servers.
+Use either the default recipe or the app_lb recipe.
+
+When using the default recipe, modify the haproxy.cfg.erb file with listener(s) for your sites/servers.
The app_lb recipe is designed to be used with the application cookbook, and provides search mechanism to find the appropriate application servers. Set this in a role that includes the haproxy::app_lb recipe. For example,
@@ -41,10 +43,10 @@ The search also relies on an attribute "app_environment" being set on the node a
)
= LICENSE and AUTHOR:
-
+
Author:: Joshua Timberman (<joshua@opscode.com>)
-Copyright:: 2009, Opscode, Inc
+Copyright:: 2009-2010, Opscode, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
View
22 haproxy/attributes/default.rb
@@ -0,0 +1,22 @@
+#
+# Cookbook Name:: haproxy
+# Default:: default
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+default['haproxy']['member_port'] = "8080"
+default['haproxy']['enable_admin'] = true
+default['haproxy']['app_server_role'] = "webserver"
View
4 haproxy/metadata.json
@@ -1,7 +1,7 @@
{
"name": "haproxy",
"description": "Installs and configures haproxy",
- "long_description": "= DESCRIPTION:\n\nInstalls haproxy and prepares the configuration location.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10.\n\n== Cookbooks:\n\n= ATTRIBUTES: \n\nNo haproxy-specific attributes are used in the default recipe.\n\nThe app_lb recipe can search for a user defined role name to load balance. \n\n= USAGE:\n\nFor the default recipe, update the haproxy.cfg file with listener(s) for your sites/servers.\n\nThe app_lb recipe is designed to be used with the application cookbook, and provides search mechanism to find the appropriate application servers. Set this in a role that includes the haproxy::app_lb recipe. For example,\n\n name \"load_balancer\"\n description \"haproxy load balancer\"\n run_list(\"recipe[haproxy::app_lb]\")\n override_attributes(\n \"haproxy\" => {\n \"app_server_role\" => \"webserver\"\n }\n )\n\nThe search also relies on an attribute \"app_environment\" being set on the node and a role named with the same value. For example, production:\n\n\n name \"production\"\n description \"Nodes in the production environment.\"\n default_attributes(\n \"app_environment\" => \"production\"\n )\n\n= LICENSE and AUTHOR:\n \nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "long_description": "= DESCRIPTION:\n\nInstalls haproxy and prepares the configuration location.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10 and higher.\n\n== Cookbooks:\n\n= ATTRIBUTES:\n\n* `node['haproxy']['member_port']` - the port that member systems will be listening on, default 80\n* `node['haproxy']['enable_admin']` - whether to enable the admin interface. default true. Listens on port 22002.\n* `node['haproxy']['app_server_role']` - used by the `app_lb` recipe to search for a specific role of member systems. Default `webserver`.\n\n= USAGE:\n\nUse either the default recipe or the app_lb recipe.\n\nWhen using the default recipe, modify the haproxy.cfg.erb file with listener(s) for your sites/servers.\n\nThe app_lb recipe is designed to be used with the application cookbook, and provides search mechanism to find the appropriate application servers. Set this in a role that includes the haproxy::app_lb recipe. For example,\n\n name \"load_balancer\"\n description \"haproxy load balancer\"\n run_list(\"recipe[haproxy::app_lb]\")\n override_attributes(\n \"haproxy\" => {\n \"app_server_role\" => \"webserver\"\n }\n )\n\nThe search also relies on an attribute \"app_environment\" being set on the node and a role named with the same value. For example, production:\n\n\n name \"production\"\n description \"Nodes in the production environment.\"\n default_attributes(\n \"app_environment\" => \"production\"\n )\n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright:: 2009-2010, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
@@ -33,5 +33,5 @@
"haproxy": "Installs and configures haproxy",
"haproxy::app_lb": "Installs and configures haproxy by searching for nodes of a particular role"
},
- "version": "0.8.0"
+ "version": "0.8.1"
}
View
2 haproxy/metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs and configures haproxy"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.8.0"
+version "0.8.1"
recipe "haproxy", "Installs and configures haproxy"
recipe "haproxy::app_lb", "Installs and configures haproxy by searching for nodes of a particular role"
View
4 haproxy/templates/default/haproxy-app_lb.cfg.erb
@@ -25,8 +25,10 @@ listen application 0.0.0.0:80
balance roundrobin
<% @pool_members.each do |member| -%>
<% server_ip = member.has_key?("ec2") ? member["ec2"]["public_ipv4"] : member["ipaddress"] -%>
- server <%= member["hostname"] %> <%= server_ip %>:80 weight 1 maxconn 1 check
+ server <%= member["hostname"] %> <%= server_ip %>:<%= node["haproxy"]["member_port"] %> weight 1 maxconn 1 check
<% end -%>
+<% if node["haproxy"]["enable_admin"] -%>
listen admin 0.0.0.0:22002
mode http
stats uri /
+<% end -%>

0 comments on commit dea88e3

Please sign in to comment.
Something went wrong with that request. Please try again.