diff --git a/tasks/blacklists.yml b/tasks/blacklists.yml new file mode 100644 index 0000000000000000000000000000000000000000..9cc0294a2adffbb36f8ef051f2343233260487bc --- /dev/null +++ b/tasks/blacklists.yml @@ -0,0 +1,15 @@ +--- +# file: roles/haproxy/tasks/blacklists.yml + +- name: "Update blacklists" + template: + src: '{{ item }}' + dest: '/etc/haproxy/{{ item }}' + owner: 'root' + group: 'root' + mode: '644' + with_items: + - 'blacklist.ip' + - 'blacklist.referer' + - 'blacklist.agent' + notify: "Check HAProxy Config" diff --git a/tasks/configure.yml b/tasks/configure.yml index 09b168ff6147a01dbfedd4e8230ecda1252a2594..daa142ed5becb4c9e95257ab2bb862313e3f61c9 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -72,19 +72,6 @@ with_items: '{{ groups.webserver|default([]) }}' changed_when: false -- name: "Update blacklists" - template: - src='{{ item }}' - dest='/etc/haproxy/{{ item }}' - owner='root' - group='root' - mode='644' - with_items: - - 'blacklist.ip' - - 'blacklist.referer' - - 'blacklist.agent' - notify: "Check HAProxy Config" - - name: "Update private ips" template: src='privatelist.ip.jinja2' diff --git a/tasks/main.yml b/tasks/main.yml index 8d30eb10bc55aad316b6f2f9b366a7423fa47d97..8e91062c52d0308c3a45673ae83ecb317f8a712d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,7 +9,12 @@ - import_tasks: install.yml - import_tasks: configure.yml - tags: 'Config' + tags: + - 'Config' + - import_tasks: blacklists.yml + tags: + - 'Config' + - 'Blacklists' when: '"haproxy" not in excluded_roles' diff --git a/templates/blacklist.agent b/templates/blacklist.agent index cabc010c816841aa9c9df18156e0da1d36ba8c2c..a54ecabc15d737b1b5459fb7343c5482075e55f7 100644 --- a/templates/blacklist.agent +++ b/templates/blacklist.agent @@ -1,3 +1,8 @@ +{% if ansible_local is defined and ansible_local.blacklist is defined %} +{% for line in ansible_local.blacklist.agent|default([]) %} +{{line}} +{% endfor %} +{% endif %} {% for line in proxy_blacklist.agent|default([]) %} {{line}} {% endfor %} diff --git a/templates/blacklist.ip b/templates/blacklist.ip index 0208f40fdc4ed7ee272ffd386e3d064cf1681af7..672e16553421adb1737e6526b3a9cc526c7e3e56 100644 --- a/templates/blacklist.ip +++ b/templates/blacklist.ip @@ -1,3 +1,8 @@ +{% if ansible_local is defined and ansible_local.blacklist is defined %} +{% for line in ansible_local.blacklist.ip|default([]) %} +{{line}} +{% endfor %} +{% endif %} {% for line in proxy_blacklist.ip|default([]) %} {{line}} {% endfor %} diff --git a/templates/blacklist.referer b/templates/blacklist.referer index 6f24a2a6dc457891b0962f0b6b707d132ddc56a2..1e8fa994b8ccefa8b0db015b1af3c773d15c04b9 100644 --- a/templates/blacklist.referer +++ b/templates/blacklist.referer @@ -1,3 +1,8 @@ +{% if ansible_local is defined and ansible_local.blacklist is defined %} +{% for line in ansible_local.blacklist.referer|default([]) %} +{{line}} +{% endfor %} +{% endif %} {% for line in proxy_blacklist.referer|default([]) %} {{line}} {% endfor %}