From 186e3ff67bd041c1f54c531a0150082daab4b3e6 Mon Sep 17 00:00:00 2001
From: "p.artamonov"
Date: Tue, 27 Apr 2021 19:37:41 +0300
Subject: [PATCH 1/3] add_maps
---
README.md | 2 ++
tasks/configuration.yml | 11 +++++++++++
templates/etc/map.map.j2 | 3 +++
3 files changed, 16 insertions(+)
create mode 100644 templates/etc/map.map.j2
diff --git a/README.md b/README.md
index cbd57eb..73f6f74 100644
--- a/README.md
+++ b/README.md
@@ -203,6 +203,8 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_listen.{n}.default_server_params`: [optional]: Default server params applied for each server for this particular listen entry.
* `haproxy_listen.{n}.raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section
+* `haproxy_map.{n}.name|value`: [optional]: Add map in /etc/haproxy/{n}.map
+
* `haproxy_frontend`: [default: `[]`]: Front-end declarations
* `haproxy_frontend.{n}.name`: [required]: The name of the section (e.g. `https`)
* `haproxy_frontend.{n}.description`: [optional]: A description of the section (e.g. `Front-end for all HTTPS traffic`)
diff --git a/tasks/configuration.yml b/tasks/configuration.yml
index b827132..23f1216 100644
--- a/tasks/configuration.yml
+++ b/tasks/configuration.yml
@@ -1,4 +1,15 @@
# tasks file
+- name: Generate map files from templates
+ template:
+ src: "etc/haproxy/map.map.j2"
+ dest: "/etc/haproxy/{{ item.key }}.map"
+ with_items: "{{ haproxy_map | dict2items }}"
+ when: haproxy_map is defined
+ notify:
+ - restart haproxy
+ tags:
+ - haproxy-configuration-update-file
+
---
- name: configuration | update file
template:
diff --git a/templates/etc/map.map.j2 b/templates/etc/map.map.j2
new file mode 100644
index 0000000..f73a274
--- /dev/null
+++ b/templates/etc/map.map.j2
@@ -0,0 +1,3 @@
+{% for value in item.value %}
+{{ value.name }}: {{ value.value }}
+{% endfor %}
From 256f835815fbb7e89a2945127fff98c467dd353b Mon Sep 17 00:00:00 2001
From: "p.artamonov"
Date: Tue, 27 Apr 2021 21:09:29 +0300
Subject: [PATCH 2/3] add_maps
---
tasks/configuration.yml | 3 ++-
templates/etc/{ => haproxy}/map.map.j2 | 0
2 files changed, 2 insertions(+), 1 deletion(-)
rename templates/etc/{ => haproxy}/map.map.j2 (100%)
diff --git a/tasks/configuration.yml b/tasks/configuration.yml
index 23f1216..4acd5fc 100644
--- a/tasks/configuration.yml
+++ b/tasks/configuration.yml
@@ -1,4 +1,5 @@
# tasks file
+---
- name: Generate map files from templates
template:
src: "etc/haproxy/map.map.j2"
@@ -10,7 +11,7 @@
tags:
- haproxy-configuration-update-file
----
+
- name: configuration | update file
template:
src: "{{ haproxy_conf_template }}"
diff --git a/templates/etc/map.map.j2 b/templates/etc/haproxy/map.map.j2
similarity index 100%
rename from templates/etc/map.map.j2
rename to templates/etc/haproxy/map.map.j2
From a9868eab34d877e011777a9646e510a3fbc2b532 Mon Sep 17 00:00:00 2001
From: pitart
Date: Mon, 17 May 2021 19:49:15 +0300
Subject: [PATCH 3/3] Update map.map.j2
---
templates/etc/haproxy/map.map.j2 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/etc/haproxy/map.map.j2 b/templates/etc/haproxy/map.map.j2
index f73a274..5861c0a 100644
--- a/templates/etc/haproxy/map.map.j2
+++ b/templates/etc/haproxy/map.map.j2
@@ -1,3 +1,3 @@
{% for value in item.value %}
-{{ value.name }}: {{ value.value }}
+{{ value.name }} {{ value.value }}
{% endfor %}