blob: 6f7a0b0e43ce9b7c3f1e6c47e9c2094ba900d919 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
---
- name: "Copying over haproxy config for {{ project_name }}"
vars:
service: "{{ item.value }}"
haproxy_templates:
- "{{ node_custom_config }}/haproxy-config/{{ inventory_hostname }}/{{ item.key }}.cfg"
- "{{ node_custom_config }}/haproxy-config/{{ item.key }}.cfg"
- "{{ node_custom_config }}/haproxy-config/{{ inventory_hostname }}/{{ haproxy_service_template }}"
- "{{ node_custom_config }}/haproxy-config/{{ haproxy_service_template }}"
- "templates/{{ haproxy_service_template }}"
template_file: "{{ query('first_found', haproxy_templates) | first }}"
ansible.builtin.template:
src: "{{ template_file }}"
dest: "{{ node_config_directory }}/haproxy/services.d/{{ item.key }}.cfg"
mode: "0660"
become: true
when:
- service.enabled | bool
- service.haproxy is defined
- enable_haproxy | bool
with_dict: "{{ project_services }}"
- name: "Add configuration when using single external frontend for {{ project_name }}"
vars:
service: "{{ item.value }}"
ansible.builtin.blockinfile:
create: true
path: "{{ node_config_directory }}/haproxy/external-frontend-map"
insertafter: EOF
marker: "# {mark} {{ item.key }}"
mode: "0660"
block: |
{%- set haproxy = service.haproxy | default({}) %}
{%- for haproxy_name, haproxy_service in haproxy.items() %}
{% set external = haproxy_service.external | default(false) | bool %}
{% set enabled = haproxy_service.enabled | default(false) | bool %}
{% set with_frontend = haproxy_service.with_frontend | default(true) | bool %}
{% set mode = haproxy_service.mode | default('http') %}
{%- if external and with_frontend and enabled and mode == 'http' %}
{{ haproxy_service.external_fqdn }} {{ haproxy_name }}_back
{% endif -%}
{%- endfor -%}
become: true
with_dict: "{{ project_services }}"
when:
- haproxy_single_external_frontend | bool
- service.enabled | bool
- service.haproxy is defined
- enable_haproxy | bool
- name: "Configuring firewall for {{ project_name }}"
ansible.posix.firewalld:
immediate: true
offline: true
permanent: true
port: "{{ item.value.port }}/tcp"
state: "enabled"
zone: "{{ external_api_firewalld_zone }}"
become: true
when:
- enable_haproxy | bool
- item.value.enabled | bool
- item.value.port is defined
- item.value.external | default('false') | bool
- enable_external_api_firewalld | bool
- kolla_action != "config"
with_dict: "{{ project_services | extract_haproxy_services }}"
|