diff --git a/resources/haproxy_config/actions/update.yml b/resources/haproxy_config/actions/update.yml new file mode 100644 index 00000000..318b779b --- /dev/null +++ b/resources/haproxy_config/actions/update.yml @@ -0,0 +1,22 @@ +# TODO +- hosts: [{{ip}}] + sudo: yes + vars: + config_dir: {src: {{ config_dir.value['src'] }}, dst: {{ config_dir.value['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 %} + {% endfor %} + tasks: + - file: path={{ config_dir.value['src'] }}/ state=directory + - file: path={{ config_dir.value['src'] }}/haproxy.cfg state=touch + - template: src={{ resource_dir }}/templates/haproxy.cfg dest=/etc/haproxy/haproxy.cfg