Split riak cluster into smaller pieces

This commit is contained in:
Łukasz Oleś 2015-09-29 14:40:41 +02:00
parent 3ba878727f
commit 0092c72280
3 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,50 @@
id: haproxy_riak_config
resources:
- id: haproxy_riak_config_http
from: resources/haproxy_service_config
tags: ['service=riak', 'protocol=http']
values:
listen_port: {{http_listen_port}}
protocol: 'http'
name: 'riak_haproxy_http'
backends:server:
{% for riak in riaks %}
- {{riak}}::riak_hostname
{% endfor %}
backends:port:
{% for riak in riaks %}
- {{riak}}::riak_port_http
{% endfor %}
- id: haproxy_riak_config_pb
from: resources/haproxy_service_config
tags: ['service=riak', 'protocol=tcp']
values:
listen_port: {{pb_listen_port}}
protocol: 'tcp'
name: 'riak_haproxy_pb'
backends:server:
{% for riak in riaks %}
- {{riak}}::riak_hostname
{% endfor %}
backends:port:
{% for riak in riaks %}
- {{riak}}::riak_port_pb
{% endfor %}
updates:
- with_tags: ['resource=haproxy_config']
values:
config:protocol:
- haproxy_riak_config_http::protocol
- haproxy_riak_config_pb::protocol
config:listen_port:
- haproxy_riak_config_http::listen_port
- haproxy_riak_config_pb::listen_port
config:name:
- haproxy_riak_config_http::name
- haproxy_riak_config_pb::name
config:backends:
- haproxy_riak_config_http::backends
- haproxy_riak_config_pb::backends

View File

@ -0,0 +1,61 @@
id: riak_service
resources:
- id: riak_service{{index}}
from: resources/riak_node
location: {{node}}
values:
riak_self_name: riak{{index}}
riak_hostname: riak_server{{index}}.solar
riak_name: riak{{index}}@riak_server{{index}}.solar
{% if join_to %}
join_to: {{join_to}}::riak_name
{% endif %}
ip: {{node}}::ip
updates:
- with_tags: ['resource=hosts_file']
values:
hosts:name:
- riak_service{{index}}::riak_hostname::NO_EVENTS
hosts:ip:
- riak_service{{index}}::ip::NO_EVENTS
- with_tags: ['resource=haproxy_service_config', 'service=riak', 'protocol=http']
values:
backends:server:
- riak_service{{index}}::riak_hostname
backends:port:
- riak_service{{index}}::riak_port_http
- with_tags: ['resource=haproxy_service_config', 'service=riak', 'protocol=tcp']
values:
backends:server:
- riak_service{{index}}::riak_hostname
backends:port:
- riak_service{{index}}::riak_port_pb
events:
- type: depends_on
parent:
with_tags: ['resource=hosts_file', 'location={{node}}']
action: run
state: success
depend_action: riak_service{{index}}.run
{% if join_to %}
- type: react_on
parent_action: riak_service{{index}}.run
state: success
depend_action: riak_service{{index}}.join
- type: react_on
parent_action: riak_service{{index}}.leave
state: success
depend_action: riak_service{{index}}.join
- type: react_on
parent_action: riak_service{{index}}.join
state: success
depend_action: {{join_to}}.commit
{% endif %}

46
templates/haproxy.yaml Normal file
View File

@ -0,0 +1,46 @@
id: haproxy
resources:
- id: haproxy_config{{index}}
from: resources/haproxy_config
location: {{node}}
values:
ip: '{{node}}::ip'
config:protocol:
{% for config in service_configs %}
- {{config}}::protocol
{% endfor %}
config:listen_port:
{% for config in service_configs %}
- {{config}}::listen_port
{% endfor %}
config:name:
{% for config in service_configs %}
- {{config}}::name
{% endfor %}
config:backends:
{% for config in service_configs %}
- {{config}}::backends
{% endfor %}
- id: haproxy_service{{index}}
location: {{node}}
from: resources/haproxy_service
values:
ip: '{{node}}::ip'
events:
- type: depends_on
parent_action: 'haproxy_service{{index}}.run'
state: 'success'
depend_action: 'haproxy_config{{index}}.run'
- type: react_on
parent_action: 'haproxy_config{{index}}.run'
state: 'success'
depend_action: 'haproxy_service{{index}}.apply_config'
- type: react_on
parent_action: 'haproxy_config{{index}}.update'
state: 'success'
depend_action: 'haproxy_service{{index}}.apply_config'