GHP publish
This commit is contained in:
3
roles/haproxy/defaults/main.yaml
Normal file
3
roles/haproxy/defaults/main.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
dockerize: false
|
||||
namespace: haproxy
|
||||
haproxy_image_tag: 2.3.1
|
22
roles/haproxy/handlers/main.yml
Normal file
22
roles/haproxy/handlers/main.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: restart haproxy
|
||||
become: true
|
||||
systemd:
|
||||
name: haproxy
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
|
||||
- name: restart docker haproxy
|
||||
docker_container:
|
||||
name: "haproxy"
|
||||
image: "{{ docker_registry }}/haproxy:{{ haproxy_image_tag }}"
|
||||
state: started
|
||||
restart: yes
|
||||
ports:
|
||||
- "443:443"
|
||||
container_default_behavior: no_defaults
|
||||
detach: true
|
||||
restart_policy: unless-stopped
|
||||
volumes:
|
||||
- "/opt/haproxy/conf.d:/usr/local/etc/haproxy/conf.d"
|
||||
|
0
roles/haproxy/meta/main.yml
Normal file
0
roles/haproxy/meta/main.yml
Normal file
26
roles/haproxy/tasks/docker.yml
Normal file
26
roles/haproxy/tasks/docker.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Create configuration dir for {{ namespace }}
|
||||
file:
|
||||
name: "/opt/haproxy/conf.d"
|
||||
state: directory
|
||||
|
||||
- name: Copy haproxy configuration files for {{ namespace }}
|
||||
copy:
|
||||
content: "{{ item.data }}"
|
||||
dest: "/opt/haproxy/conf.d/{{ item.name }}"
|
||||
loop: "{{ haproxy['conf.d'] }}"
|
||||
when: haproxy['conf.d'] is defined
|
||||
notify: restart docker haproxy
|
||||
|
||||
- name: Start haproxy in docker for {{ namespace }}
|
||||
docker_container:
|
||||
name: "haproxy"
|
||||
image: "{{ docker_registry }}/haproxy:{{ haproxy_image_tag }}"
|
||||
state: started
|
||||
ports:
|
||||
- "443:443"
|
||||
container_default_behavior: no_defaults
|
||||
detach: true
|
||||
restart_policy: unless-stopped
|
||||
volumes:
|
||||
- "/opt/haproxy/conf.d:/usr/local/etc/haproxy/conf.d"
|
10
roles/haproxy/tasks/main.yml
Normal file
10
roles/haproxy/tasks/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
- block:
|
||||
- import_tasks: package.yml
|
||||
when: not dockerize
|
||||
become: true
|
||||
|
||||
- block:
|
||||
- import_tasks: docker.yml
|
||||
when: dockerize
|
||||
become: true
|
||||
|
22
roles/haproxy/tasks/package.yml
Normal file
22
roles/haproxy/tasks/package.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
- block:
|
||||
- name: install haproxy
|
||||
package:
|
||||
name: haproxy
|
||||
state: present
|
||||
|
||||
- name: add haproxy config
|
||||
copy:
|
||||
content: "{{ haproxy_config }}"
|
||||
dest: "/etc/haproxy/haproxy.cfg"
|
||||
notify:
|
||||
- restart haproxy
|
||||
when: haproxy_config is defined
|
||||
|
||||
- name: start haproxy service
|
||||
systemd:
|
||||
name: haproxy
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
|
Reference in New Issue
Block a user