Merge "Make haproxy role more generic"
This commit is contained in:
commit
c663d9b4ea
inventory/service/group_vars
playbooks
@ -1,4 +1,4 @@
|
|||||||
haproxy_listeners:
|
gitea_lb_listeners:
|
||||||
- name: balance_git_http
|
- name: balance_git_http
|
||||||
bind:
|
bind:
|
||||||
- ':::80'
|
- ':::80'
|
||||||
|
9
playbooks/roles/gitea-lb/README.rst
Normal file
9
playbooks/roles/gitea-lb/README.rst
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Install the gitea-lb services
|
||||||
|
|
||||||
|
This configures haproxy
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: gitea_lb_listeners
|
||||||
|
|
||||||
|
The backends to configure
|
5
playbooks/roles/gitea-lb/tasks/main.yaml
Normal file
5
playbooks/roles/gitea-lb/tasks/main.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
- name: Install haproxy with gitea config
|
||||||
|
include_role:
|
||||||
|
name: haproxy
|
||||||
|
vars:
|
||||||
|
haproxy_config_template: gitea-haproxy.cfg.j2
|
@ -20,7 +20,7 @@ defaults
|
|||||||
timeout server 2m
|
timeout server 2m
|
||||||
timeout check 10s
|
timeout check 10s
|
||||||
|
|
||||||
{% for listener in haproxy_listeners %}
|
{% for listener in gitea_lb_listeners %}
|
||||||
listen {{ listener.name }}
|
listen {{ listener.name }}
|
||||||
{% for bind in listener.bind %}
|
{% for bind in listener.bind %}
|
||||||
bind {{ bind }}
|
bind {{ bind }}
|
@ -1 +1,16 @@
|
|||||||
Install, configure, and run a haproxy server.
|
Install, configure, and run a haproxy server.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: haproxy_config_template
|
||||||
|
:type: string
|
||||||
|
:default: Undefined
|
||||||
|
|
||||||
|
The config template to install for haproxy. Must be defined.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: haproxy_run_statsd
|
||||||
|
:type: string
|
||||||
|
:default: True
|
||||||
|
|
||||||
|
Run the ``haproxy-statsd`` docker container to report back-end
|
||||||
|
stats to graphite.opendev.org
|
||||||
|
1
playbooks/roles/haproxy/defaults/main.yaml
Normal file
1
playbooks/roles/haproxy/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
haproxy_run_statsd: True
|
@ -2,10 +2,7 @@
|
|||||||
package:
|
package:
|
||||||
name: socat
|
name: socat
|
||||||
state: present
|
state: present
|
||||||
- name: Synchronize docker-compose directory
|
|
||||||
synchronize:
|
|
||||||
src: docker/
|
|
||||||
dest: /etc/haproxy-docker/
|
|
||||||
- name: Ensure registry volume directories exists
|
- name: Ensure registry volume directories exists
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
@ -15,19 +12,47 @@
|
|||||||
loop:
|
loop:
|
||||||
- etc
|
- etc
|
||||||
- run
|
- run
|
||||||
|
|
||||||
|
- name: Ensure haproxy config template available
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- haproxy_config_template is defined
|
||||||
|
|
||||||
- name: Write haproxy config file
|
- name: Write haproxy config file
|
||||||
template:
|
template:
|
||||||
src: haproxy.cfg.j2
|
src: '{{ haproxy_config_template }}'
|
||||||
dest: /var/haproxy/etc/haproxy.cfg
|
dest: /var/haproxy/etc/haproxy.cfg
|
||||||
|
owner: 1000
|
||||||
|
group: 1000
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Ensure docker compose configuration directory
|
||||||
|
file:
|
||||||
|
path: /etc/haproxy-docker
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Install docker-compose configuration
|
||||||
|
template:
|
||||||
|
src: docker-compose.yaml.j2
|
||||||
|
dest: /etc/haproxy-docker/docker-compose.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
notify: Reload haproxy
|
notify: Reload haproxy
|
||||||
- name: Run docker-compose pull
|
- name: Run docker-compose pull
|
||||||
shell:
|
shell:
|
||||||
cmd: docker-compose pull
|
cmd: docker-compose pull
|
||||||
chdir: /etc/haproxy-docker/
|
chdir: /etc/haproxy-docker/
|
||||||
|
|
||||||
- name: Run docker-compose up
|
- name: Run docker-compose up
|
||||||
shell:
|
shell:
|
||||||
cmd: docker-compose up -d
|
cmd: docker-compose up -d
|
||||||
chdir: /etc/haproxy-docker/
|
chdir: /etc/haproxy-docker/
|
||||||
|
|
||||||
- name: Run docker prune to cleanup unneeded images
|
- name: Run docker prune to cleanup unneeded images
|
||||||
shell:
|
shell:
|
||||||
cmd: docker image prune -f
|
cmd: docker image prune -f
|
||||||
|
@ -42,6 +42,8 @@ services:
|
|||||||
driver: syslog
|
driver: syslog
|
||||||
options:
|
options:
|
||||||
tag: "docker-haproxy"
|
tag: "docker-haproxy"
|
||||||
|
|
||||||
|
{% if haproxy_run_statsd %}
|
||||||
haproxy-statsd:
|
haproxy-statsd:
|
||||||
restart: always
|
restart: always
|
||||||
image: docker.io/opendevorg/haproxy-statsd:latest
|
image: docker.io/opendevorg/haproxy-statsd:latest
|
||||||
@ -56,3 +58,4 @@ services:
|
|||||||
driver: syslog
|
driver: syslog
|
||||||
options:
|
options:
|
||||||
tag: "docker-haproxy-statsd"
|
tag: "docker-haproxy-statsd"
|
||||||
|
{% endif %}
|
@ -3,4 +3,4 @@
|
|||||||
roles:
|
roles:
|
||||||
- iptables
|
- iptables
|
||||||
- install-docker
|
- install-docker
|
||||||
- haproxy
|
- gitea-lb
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
haproxy_listeners:
|
gitea_lb_listeners:
|
||||||
- name: balance_git_http
|
- name: balance_git_http
|
||||||
bind:
|
bind:
|
||||||
- ":::80"
|
- ":::80"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user