From fcdf349a9706bdee0e3cf0a77a3545d5782c46f8 Mon Sep 17 00:00:00 2001 From: vyasswaroop Date: Thu, 28 May 2020 15:13:19 +0530 Subject: [PATCH] Making haproxy compactable with ansible v2.9.9 --- tasks/main.yml | 91 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f1e0143..39b4dd5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,55 +1,86 @@ --- -- name: 'Installs haproxy' - apt: pkg=haproxy state=installed +- name: Installs haproxy + apt: + pkg: + - haproxy + state: latest -- name: 'Enable it' - copy: src='haproxy-default' dest='/etc/default/haproxy' +- name: Enable it + copy: + src: haproxy-default + dest: /etc/default/haproxy -- name: 'Create directory for the frontend' - file: path='/etc/haproxy/frontends.d' state=directory +- name: Create directory for the frontend + file: + path: /etc/haproxy/frontends.d + state: directory -- name: 'Empty the folder if not already empty' - command: rm -f /etc/haproxy/backends.d/*.cfg +- name: Empty the folder if not already empty + file: + path: /etc/haproxy/frontends.d/*.cfg + state: absent -- name: 'Build up the frontends' - template: src=frontend.cfg dest=/etc/haproxy/frontends.d/{{ item.name }}.cfg +- name: Build up the frontends + template: + src: frontend.cfg + dest: /etc/haproxy/frontends.d/{{ item.name }}.cfg with_items: " {{ haproxy_frontends }} " when: haproxy_frontends is defined -- name: 'Create directory for the backends' - file: path='/etc/haproxy/backends.d' state=directory +- name: Create directory for the backends + file: + path: /etc/haproxy/backends.d + state: directory -- name: 'Empty the folder if not already empty' - command: rm -f /etc/haproxy/backends.d/*.cfg +- name: Empty the folder if not already empty + file: + path: /etc/haproxy/backends.d/*.cfg + state: absent -- name: 'Build up the backends' - template: src=backend.cfg dest=/etc/haproxy/backends.d/{{ item.name }}.cfg +- name: Build up the backends + template: + src: backend.cfg + dest: /etc/haproxy/backends.d/{{ item.name }}.cfg with_items: " {{ haproxy_backends }} " when: haproxy_backends is defined -- name: 'Create the compiled folder' - file: path='/etc/haproxy/compiled' state=directory +- name: Create the compiled folder + file: + path: /etc/haproxy/compiled + state: directory -- name: 'Empty the folder if not already empty' - command: rm -f /etc/haproxy/compiled/*.cfg +- name: Empty the folder if not already empty + file: + path: /etc/haproxy/compiled/*.cfg + state: absent -- name: 'Build up the global config' - template: src=global.cfg dest=/etc/haproxy/compiled/01-global.cfg +- name: Build up the global config + template: + src: global.cfg + dest: /etc/haproxy/compiled/01-global.cfg when: haproxy_global is defined tags: 'test' -- name: 'Build up the default config' - template: src=defaults.cfg dest=/etc/haproxy/compiled/02-defaults.cfg +- name: Build up the default config + template: + src: defaults.cfg + dest: /etc/haproxy/compiled/02-defaults.cfg when: haproxy_defaults is defined # Here we have to go through multiple assemble calls, # we can't assemble multiple folders into the same destination -- name: 'Assemble the backends configuration file' - assemble: src=/etc/haproxy/backends.d dest=/etc/haproxy/compiled/03-backends.cfg +- name: Assemble the backends configuration file + assemble: + src: /etc/haproxy/backends.d + dest: /etc/haproxy/compiled/03-backends.cfg -- name: 'Assemble the frontends configuration file' - assemble: src=/etc/haproxy/frontends.d dest=/etc/haproxy/compiled/04-frontends.cfg +- name: Assemble the frontends configuration file + assemble: + src: /etc/haproxy/frontends.d + dest: /etc/haproxy/compiled/04-frontends.cfg -- name: 'Assemble the final configuration file' - assemble: src=/etc/haproxy/compiled dest=/etc/haproxy/haproxy.cfg backup=yes +- name: Assemble the final configuration file + assemble: + src: /etc/haproxy/compiled + dest: /etc/haproxy/haproxy.cfg backup=yes