forked from modcloth/ansible-haproxy
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making haproxy compactable with ansible v2.9.9
- Loading branch information
1 parent
4c2ecbd
commit fcdf349
Showing
1 changed file
with
61 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |