Skip to content

Having haproxy/members attribute hashed based on backend names #58

@nitinmohan87

Description

@nitinmohan87

As of now the haproxy/members attribute adds the following 2 entries by default to the servers-http backend.
https://github.com/hw-cookbooks/haproxy/blob/master/attributes/default.rb#L26-L36
https://github.com/hw-cookbooks/haproxy/blob/master/recipes/default.rb#L57-L64

This haproxy/members can be made more helpful if we can hash the members based on backend names

node.set['haproxy']['members']['servers-http'] = [{
...
}]

This would make this attribute more helpful when we want to create additional backend sections with their own list of servers attached.

node.set['haproxy']['members']['new_backend'] = [{
...
}]

It would also be helpful to have a helper method that does this - https://github.com/hw-cookbooks/haproxy/blob/master/recipes/default.rb#L57-L59
We can probably have a options hash to set these values to the server entry - weight #{member['weight'] || member_weight} maxconn #{member['max_connections'] || member_max_conn} check"

options = {
  weight: member['weight'] || member_weight
  maxconn: member['max_connections'] || member_max_conn
  check: true
}

Wasn't this the purpose of having a haproxy/members attribute? Or I am going in the wrong direction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions