Merge pull request #163 from pigmej/riak_example_to_hash
Riak example to hash
This commit is contained in:
commit
68a884d409
@ -58,7 +58,8 @@ def setup_riak():
|
||||
for riak in riak_services:
|
||||
for hosts_file in hosts_services:
|
||||
signals.connect(riak, hosts_file,
|
||||
{'riak_hostname': 'hosts_names', 'ip': 'hosts_ips'},
|
||||
{'riak_hostname': 'hosts:name',
|
||||
'ip': 'hosts:ip'},
|
||||
events=False)
|
||||
|
||||
has_errors = False
|
||||
@ -143,33 +144,28 @@ def setup_haproxies():
|
||||
|
||||
for single_hpsc in hpsc_http:
|
||||
for riak in riaks:
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'servers',
|
||||
'riak_port_http': 'ports'})
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server',
|
||||
'riak_port_http': 'backends:port'})
|
||||
|
||||
for single_hpsc in hpsc_pb:
|
||||
for riak in riaks:
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'servers',
|
||||
'riak_port_pb': 'ports'})
|
||||
signals.connect(riak, single_hpsc, {'riak_hostname': 'backends:server',
|
||||
'riak_port_pb': 'backends:port'})
|
||||
|
||||
# haproxy config to haproxy service
|
||||
|
||||
for single_hpc, single_hpsc in zip(hpc, hpsc_http):
|
||||
signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols',
|
||||
'listen_port': 'listen_ports',
|
||||
'name': 'configs_names',
|
||||
'servers': 'configs',
|
||||
'ports': 'configs_ports'})
|
||||
signals.connect(single_hpsc, single_hpc, {"backends": "config:backends",
|
||||
"listen_port": "config:listen_port",
|
||||
"protocol": "config:protocol",
|
||||
"name": "config:name"})
|
||||
|
||||
for single_hpc, single_hpsc in zip(hpc, hpsc_pb):
|
||||
signals.connect(single_hpsc, single_hpc, {'protocol': 'configs_protocols',
|
||||
'listen_port': 'listen_ports',
|
||||
'name': 'configs_names',
|
||||
'servers': 'configs',
|
||||
'ports': 'configs_ports'})
|
||||
signals.connect(single_hpsc, single_hpc, {"backends": "config:backends",
|
||||
"listen_port": "config:listen_port",
|
||||
"protocol": "config:protocol",
|
||||
"name": "config:name"})
|
||||
|
||||
for single_hps, single_hpc in zip(hps, hpc):
|
||||
signals.connect(single_hpc, single_hps, {'listen_ports': 'ports'},
|
||||
events=False)
|
||||
|
||||
# assign haproxy services to each node
|
||||
|
||||
|
@ -2,21 +2,21 @@
|
||||
- hosts: [{{host}}]
|
||||
sudo: yes
|
||||
vars:
|
||||
config_dir: {src: {{ config_dir.value['src'] }}, dst: {{ config_dir.value['dst'] }}}
|
||||
config_dir: {src: {{ config_dir['src'] }}, dst: {{ config_dir['dst'] }}}
|
||||
haproxy_ip: {{ ip }}
|
||||
haproxy_services:
|
||||
{% for service, ports, listen_port, protocol in zip(configs.value, configs_ports.value, listen_ports.value, configs_protocols.value) %}
|
||||
- name: {{ service['emitter_attached_to'] }}
|
||||
listen_port: {{ listen_port['value'] }}
|
||||
protocol: {{ protocol['value'] }}
|
||||
servers:
|
||||
{% for server_ip, server_port in zip(service['value'], ports['value']) %}
|
||||
- name: {{ server_ip['emitter_attached_to'] }}
|
||||
ip: {{ server_ip['value'] }}
|
||||
port: {{ server_port['value'] }}
|
||||
{% endfor %}
|
||||
{% for single in config %}
|
||||
- name: {{ single['name'] }}
|
||||
listen_port: {{ single['listen_port'] }}
|
||||
protocol: {{ single['protocol'] }}
|
||||
servers:
|
||||
{% for backend in single['backends'] %}
|
||||
- name: {{ backend['server'] }}_{{ backend['port'] }}
|
||||
ip: {{ backend['server'] }}
|
||||
port: {{ backend['port'] }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
tasks:
|
||||
- file: path={{ config_dir.value['src'] }}/ state=directory
|
||||
- file: path={{ config_dir.value['src'] }}/haproxy.cfg state=touch
|
||||
- file: path={{ config_dir['src'] }}/ state=directory
|
||||
- file: path={{ config_dir['src'] }}/haproxy.cfg state=touch
|
||||
- template: src={{templates_dir}}/haproxy.cfg dest=/etc/haproxy/haproxy.cfg
|
||||
|
@ -1,22 +1,22 @@
|
||||
# TODO
|
||||
- hosts: [{{ip}}]
|
||||
- hosts: [{{host}}]
|
||||
sudo: yes
|
||||
vars:
|
||||
config_dir: {src: {{ config_dir.value['src'] }}, dst: {{ config_dir.value['dst'] }}}
|
||||
config_dir: {src: {{ config_dir['src'] }}, dst: {{ config_dir['dst'] }}}
|
||||
haproxy_ip: {{ ip }}
|
||||
haproxy_services:
|
||||
{% for service, ports, listen_port, protocol in zip(configs.value, configs_ports.value, listen_ports.value, configs_protocols.value) %}
|
||||
- name: {{ service['emitter_attached_to'] }}
|
||||
listen_port: {{ listen_port['value'] }}
|
||||
protocol: {{ protocol['value'] }}
|
||||
servers:
|
||||
{% for server_ip, server_port in zip(service['value'], ports['value']) %}
|
||||
- name: {{ server_ip['emitter_attached_to'] }}
|
||||
ip: {{ server_ip['value'] }}
|
||||
port: {{ server_port['value'] }}
|
||||
{% endfor %}
|
||||
{% for single in config %}
|
||||
- name: {{ single['name'] }}
|
||||
listen_port: {{ single['listen_port'] }}
|
||||
protocol: {{ single['protocol'] }}
|
||||
servers:
|
||||
{% for backend in single['backends'] %}
|
||||
- name: {{ backend['server'] }}_{{ backend['port'] }}
|
||||
ip: {{ backend['server'] }}
|
||||
port: {{ backend['port'] }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
tasks:
|
||||
- file: path={{ config_dir.value['src'] }}/ state=directory
|
||||
- file: path={{ config_dir.value['src'] }}/haproxy.cfg state=touch
|
||||
- file: path={{ config_dir['src'] }}/ state=directory
|
||||
- file: path={{ config_dir['src'] }}/haproxy.cfg state=touch
|
||||
- template: src={{templates_dir}}/haproxy.cfg dest=/etc/haproxy/haproxy.cfg
|
||||
|
@ -8,20 +8,8 @@ input:
|
||||
config_dir:
|
||||
schema: {src: str!, dst: str!}
|
||||
value: {src: /etc/solar/haproxy, dst: /etc/haproxy}
|
||||
listen_ports:
|
||||
schema: [int]
|
||||
value: []
|
||||
configs:
|
||||
schema: [[str]]
|
||||
value: []
|
||||
configs_names:
|
||||
schema: [str]
|
||||
value: []
|
||||
configs_ports:
|
||||
schema: [[int]]
|
||||
value: []
|
||||
configs_protocols:
|
||||
schema: [str]
|
||||
config:
|
||||
schema: [{backends: [{server: str!, port: int!}], listen_port: int!, protocol: str!, name: str!}]
|
||||
value: []
|
||||
ssh_user:
|
||||
schema: str!
|
||||
|
@ -5,17 +5,19 @@ input:
|
||||
name:
|
||||
schema: str!
|
||||
value: general_haproxy
|
||||
backends:
|
||||
schema: [{server: str!, port: int!}]
|
||||
listen_port:
|
||||
schema: int!
|
||||
value: 9999
|
||||
protocol:
|
||||
schema: str!
|
||||
value: http
|
||||
ports:
|
||||
schema: [int]
|
||||
value: []
|
||||
servers:
|
||||
schema: [str]
|
||||
value: []
|
||||
# ports:
|
||||
# schema: [int]
|
||||
# value: []
|
||||
# servers:
|
||||
# schema: [str]
|
||||
# value: []
|
||||
|
||||
tags: [resources/haproxy, resource/haproxy_general_config]
|
||||
|
@ -98,6 +98,9 @@ def _construct_jsonschema(schema, definition_base=''):
|
||||
if schema == 'bool!':
|
||||
return {'type': 'boolean'}, {}
|
||||
|
||||
print repr(schema)
|
||||
print locals()
|
||||
|
||||
if isinstance(schema, list):
|
||||
items, definitions = _construct_jsonschema(schema[0], definition_base=definition_base)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user