diff --git a/resources/haproxy_config/actions/run.yaml b/resources/haproxy_config/actions/run.yaml index 9ab8a09d..e4aaf9b9 100644 --- a/resources/haproxy_config/actions/run.yaml +++ b/resources/haproxy_config/actions/run.yaml @@ -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 diff --git a/resources/haproxy_config/actions/update.yaml b/resources/haproxy_config/actions/update.yaml index 474ee62b..e4aaf9b9 100644 --- a/resources/haproxy_config/actions/update.yaml +++ b/resources/haproxy_config/actions/update.yaml @@ -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 diff --git a/resources/haproxy_config/meta.yaml b/resources/haproxy_config/meta.yaml index 22636166..e61f0efb 100644 --- a/resources/haproxy_config/meta.yaml +++ b/resources/haproxy_config/meta.yaml @@ -8,21 +8,6 @@ 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] - # value: [] config: schema: [{backends: [{server: str!, port: int!}], listen_port: int!, protocol: str!, name: str!}] value: []