diff --git a/.kitchen.yml b/.kitchen.yml index 4ea9b0e..ae25848 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -19,3 +19,25 @@ suites: multipath: storage_type: "purestorage" aliases: [ "mysql:3624a937017bcaa64842651bf00015fea" ] +- name: customized + run_list: + - recipe[multipath::default] + attributes: + multipath: + storage_type: "customized" + defaults: + queue_without_daemon: "no" + max_fds: "max" + devices: + OPEN-d*: + vendor: "\"HP\"" + path_grouping_policy: "multibus" + rr_min_io: 1000 + HSV200: + vendor: "\"HP\"" + path_grouping_policy: "group_by_prio" + rr_min_io: 100 + Invista: + vendor: "\"EMC\"" + path_grouping_policy: "multibus" + product_blacklist: "\"LUNZ\"" diff --git a/README.md b/README.md index 501d334..e0bb588 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This cookbook provides provides the ability to configure Device Mapper Multipath MPIO for Fibre-Channel and iSCSI storage attached systems. - A generic template, as well as four vendor-specific templates are included + A generic template, a customizable template, as well as four vendor-specific templates are included within this cookbook. Included vendor-specific templates are for Equallogic iSCSI, EMC Clariion, Dell Powervault MDxxxx and PureStorage storage arrays. @@ -25,7 +25,42 @@ storage arrays. - ["blacklist_regex"]: An array of regular expressions to blacklist. Default '^sd[a]$' - ["blacklist_wwid"]: An array of World-Wide Identifiers (WWID) to blacklist. Default empty. - ["aliases"]: A colon separated mapping of WWID to assign a friendly name. Default empty. - - ["storage_type"]: Select a vendor-specific multipath template (equallogic, powervault, clariion, default) + - ["storage_type"]: Select a vendor-specific multipath template (equallogic, powervault, clariion, default, customized) + +#### Using the "customized" storage_type + +When setting ["storage_type"] = "customized", the following attributes come into play for the multipath.conf template: + +Default Attributes + + * multipath (namespace) + - ["defaults"]["user_friendly_names"] = "yes" + - use the bindings file to assign a persistent and unique alias to the multipath) + - ["defaults"]["find_multipaths"] = "yes" + - multipath will only create a device if conditions are met. See multipath man page for more detail) + +Additional custom attributes can be added to the default and devices sections with the following format: + + * multipath (namespace) + - ["defaults"]["parameter"]: Adds multipath parameter to defaults section of multipath.conf + - ["devices"]["product name"]["parameter"]: Adds multipath parameter to devices section of multipath.conf + +Note: A valid device entry requires a product value, a vendor value, and one multipath parameter. (The product value in the below example is "HSV200") + +Example: + +```json +"normal": { + "multipath": { + "default": { + "queue_without_daemon": "no" }, + "devices": { + "HSV200": { + "vendor": "\"HP\"", + "path_grouping_policy": "multibus" + } } } +} +``` ## Usage diff --git a/attributes/customized-multipath.rb b/attributes/customized-multipath.rb new file mode 100644 index 0000000..b7afdc4 --- /dev/null +++ b/attributes/customized-multipath.rb @@ -0,0 +1,2 @@ +default['multipath']['defaults']['user_friendly_names'] = "yes" +default['multipath']['defaults']['find_multipaths'] = "yes" diff --git a/templates/default/customized-multipath.conf.erb b/templates/default/customized-multipath.conf.erb new file mode 100644 index 0000000..1f7519e --- /dev/null +++ b/templates/default/customized-multipath.conf.erb @@ -0,0 +1,43 @@ +# Template dropped by Chef for <%= node["fqdn"] %> +# Local modifications will be overwritten + +defaults { + <% node["multipath"]["defaults"].each do |param,param_value| -%> + <%= param %> <%= param_value %> + <% end -%> +} + +blacklist { + <% node["multipath"]["blacklist_wwid"].each do |bl_wwid| -%> + wwid <%= bl_wwid %> + <% end -%> + <% node["multipath"]["blacklist_regex"].each do |bl_device| -%> + devnode "<%= bl_device %>" + <% end -%> + devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" + devnode "^hd[a-z][[0-9]*]" + devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]" +} + +<% unless node["multipath"]["aliases"].empty? -%> +multipaths { +<% node["multipath"]["aliases"].each do |alias_def| -%> + <% alias_arr = alias_def.split(/:/) -%> + multipath { + wwid <%= alias_arr[1] %> + alias <%= alias_arr[0] %> + } +<% end -%> +} +<% end -%> + +devices { + <% node["multipath"]["devices"].each do |product,parameters| %> + device { + product "<%= product %>" + <% parameters.each do |param,param_value| %> + <%= param %> <%= param_value %> + <% end -%> + } + <% end -%> +} diff --git a/test/integration/customized/bats/default.bats b/test/integration/customized/bats/default.bats new file mode 100644 index 0000000..0ce6dfe --- /dev/null +++ b/test/integration/customized/bats/default.bats @@ -0,0 +1,65 @@ +#!/usr/bin/env bats + +@test 'multipath configuration sets default user_friendly_names to yes' { + grep -A 1 "defaults {" /etc/multipath.conf |grep "user_friendly_names yes" +} + +@test 'multipath configuration sets default find_multipaths to yes' { + grep -A 2 "defaults {" /etc/multipath.conf |grep "find_multipaths yes" +} + +@test 'multipath configuration sets default queue_without_daemon to no' { + grep -A 3 "defaults {" /etc/multipath.conf |grep "queue_without_daemon no" +} + +@test 'multipath configuration sets default max_fds to max' { + grep -A 4 "defaults {" /etc/multipath.conf |grep "max_fds max" +} + +@test 'multipath configuration sets device product to OPEN-d*' { + grep -A 4 "device {" /etc/multipath.conf |grep "product[[:space:]][[:punct:]]OPEN-d" +} + +@test 'multipath configuration sets OPEN-d* device vendor to HP' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 1 "product[[:space:]][[:punct:]]OPEN-d" |grep "vendor[[:space:]][[:punct:]]HP" +} + +@test 'multipath configuration sets OPEN-d* device path_grouping_policy to multibus' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 2 "product[[:space:]][[:punct:]]OPEN-d" |grep "path_grouping_policy[[:space:]]multibus" +} + +@test 'multipath configuration sets OPEN-d* device rr_min_io to 1000' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 3 "product[[:space:]][[:punct:]]OPEN-d" |grep "rr_min_io[[:space:]]1000\>" +} + +@test 'multipath configuration sets device product to HSV200' { + grep -A 4 "device {" /etc/multipath.conf |grep "product[[:space:]][[:punct:]]HSV200" +} + +@test 'multipath configuration sets HSV200 device vendor to HP' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 1 "product[[:space:]][[:punct:]]HSV200" |grep "vendor[[:space:]][[:punct:]]HP" +} + +@test 'multipath configuration sets HSV200 device path_grouping_policy to group_by_prio' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 2 "product[[:space:]][[:punct:]]HSV200" |grep "path_grouping_policy[[:space:]]group_by_prio" +} + +@test 'multipath configuration sets HSV200 device rr_min_io to 1000' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 3 "product[[:space:]][[:punct:]]HSV200" |grep "rr_min_io[[:space:]]100\>" +} + +@test 'multipath configuration sets device product to Invista' { + grep -A 4 "device {" /etc/multipath.conf |grep "product[[:space:]][[:punct:]]Invista" +} + +@test 'multipath configuration sets Invista device vendor to EMC' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 1 "product[[:space:]][[:punct:]]Invista" |grep "vendor[[:space:]][[:punct:]]EMC" +} + +@test 'multipath configuration sets Invista device path_grouping_policy to multibus' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 2 "product[[:space:]][[:punct:]]Invista" |grep "path_grouping_policy[[:space:]]multibus" +} + +@test 'multipath configuration sets Invista device product_blacklist to LUNZ' { + grep -A 4 "device {" /etc/multipath.conf |grep -A 3 "product[[:space:]][[:punct:]]Invista" |grep "product_blacklist[[:space:]][[:punct:]]LUNZ\>" +}