feat(install): add docker install and replace base image to haproxytech/haproxy-debian because of chroot issues
This commit is contained in:
parent
2de8c3fb1a
commit
9caa950236
@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
# defaults file for deploy_haproxy
|
# defaults file for deploy_haproxy
|
||||||
deploy_haproxy_deploy_method: host # deployment method, either host or docker
|
deploy_haproxy_deploy_method: host # deployment method, either host or docker
|
||||||
deploy_haproxy_version: "2.6"
|
deploy_haproxy_version: latest
|
||||||
|
|
||||||
deploy_haproxy_env_variables: {}
|
deploy_haproxy_env_variables: {}
|
||||||
|
deploy_haproxy_start_service: true
|
||||||
|
|
||||||
# docker-only options
|
# docker-only options
|
||||||
deploy_haproxy_container_expose_ports: []
|
|
||||||
deploy_haproxy_extra_container_volumes: []
|
deploy_haproxy_extra_container_volumes: []
|
||||||
|
|
||||||
# Options from the "default" config block in haproxy.cfg
|
# Options from the "default" config block in haproxy.cfg
|
||||||
@ -29,39 +29,44 @@ deploy_haproxy_defaults:
|
|||||||
- timeout server 5000
|
- timeout server 5000
|
||||||
|
|
||||||
deploy_haproxy_frontends:
|
deploy_haproxy_frontends:
|
||||||
- name: default
|
[]
|
||||||
options:
|
# - name: default
|
||||||
- description default frontend
|
# options:
|
||||||
- mode http
|
# - description default frontend
|
||||||
- bind :80
|
# - mode http
|
||||||
- default_backend default
|
# - bind :80
|
||||||
|
# - default_backend default
|
||||||
|
|
||||||
deploy_haproxy_backends:
|
deploy_haproxy_backends:
|
||||||
- name: default
|
[]
|
||||||
options:
|
# - name: default
|
||||||
- description default backend
|
# options:
|
||||||
- option forwardfor
|
# - description default backend
|
||||||
- option httpchk
|
# - option forwardfor
|
||||||
- http-check send meth GET uri /
|
# - option httpchk
|
||||||
- server srv_nginx1 172.17.0.4:80 check inter 5s
|
# - http-check send meth GET uri /
|
||||||
- server srv_nginx2 172.17.0.3:80 check inter 5s
|
# - server srv_nginx1 172.17.0.4:80 check inter 5s
|
||||||
|
# - server srv_nginx2 172.17.0.3:80 check inter 5s
|
||||||
|
|
||||||
|
# listen configuration blocks
|
||||||
|
# the default values expose a monitoring listener on all interfaces on port 9000
|
||||||
|
# /stats returns the haproxy dashboard (please change the user and password in the configuration)
|
||||||
|
# /health returns a 200 OK response as long as haproxy is alive and well
|
||||||
|
# /metrics returns prometheus metrics for the haproxy instance
|
||||||
deploy_haproxy_listen:
|
deploy_haproxy_listen:
|
||||||
- name: stats
|
- name: monitoring
|
||||||
options:
|
options:
|
||||||
- bind :9000
|
- bind :9000
|
||||||
- mode http
|
- mode http
|
||||||
|
- option httpchk
|
||||||
- stats enable
|
- stats enable
|
||||||
- stats uri /stats
|
- stats uri /stats
|
||||||
- stats refresh 30s
|
- stats refresh 30s
|
||||||
- stats show-desc
|
- stats show-desc
|
||||||
- stats show-legends
|
- stats show-legends
|
||||||
- stats auth admin:password
|
- stats auth admin:password
|
||||||
- name: health
|
|
||||||
options:
|
|
||||||
- bind :8000
|
|
||||||
- mode http
|
|
||||||
- option httpchk
|
|
||||||
- http-check send meth GET uri /health ver HTTP/1.1 hdr Host localhost
|
- http-check send meth GET uri /health ver HTTP/1.1 hdr Host localhost
|
||||||
- http-check expect status 200
|
- http-check expect status 200
|
||||||
- acl health_check_ok nbsrv() ge 1
|
- acl health_check_ok nbsrv() ge 1
|
||||||
- monitor-uri /health
|
- monitor-uri /health
|
||||||
|
- http-request use-service prometheus-exporter if { path /metrics }
|
||||||
|
@ -17,3 +17,4 @@
|
|||||||
state: restarted
|
state: restarted
|
||||||
listen: "systemctl-restart-haproxy"
|
listen: "systemctl-restart-haproxy"
|
||||||
throttle: 1
|
throttle: 1
|
||||||
|
when: deploy_haproxy_start_service
|
||||||
|
69
molecule/default_vagrant/group_vars/all.yml
Normal file
69
molecule/default_vagrant/group_vars/all.yml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
deploy_haproxy_deploy_method: docker # deployment method, either host or docker
|
||||||
|
deploy_haproxy_version: "2.8"
|
||||||
|
|
||||||
|
deploy_haproxy_env_variables: {}
|
||||||
|
deploy_haproxy_start_service: true
|
||||||
|
|
||||||
|
# docker-only options
|
||||||
|
deploy_haproxy_extra_container_volumes: []
|
||||||
|
|
||||||
|
# Options from the "default" config block in haproxy.cfg
|
||||||
|
# The default values here are usually set, but you can change any of them.
|
||||||
|
deploy_haproxy_global:
|
||||||
|
- log /dev/log local0
|
||||||
|
- log /dev/log local1 notice
|
||||||
|
- stats socket {{ deploy_haproxy_socket }} level admin
|
||||||
|
- chroot {{ deploy_haproxy_chroot }}
|
||||||
|
- daemon
|
||||||
|
- description hashistack haproxy
|
||||||
|
|
||||||
|
deploy_haproxy_defaults:
|
||||||
|
- log global
|
||||||
|
- mode http
|
||||||
|
- option httplog
|
||||||
|
- option dontlognull
|
||||||
|
- timeout connect 5000
|
||||||
|
- timeout client 5000
|
||||||
|
- timeout server 5000
|
||||||
|
|
||||||
|
deploy_haproxy_frontends:
|
||||||
|
- name: default
|
||||||
|
options:
|
||||||
|
- description default frontend
|
||||||
|
- mode http
|
||||||
|
- bind :1024
|
||||||
|
- default_backend default
|
||||||
|
|
||||||
|
deploy_haproxy_backends:
|
||||||
|
- name: default
|
||||||
|
options:
|
||||||
|
- description default backend
|
||||||
|
- option forwardfor
|
||||||
|
- option httpchk
|
||||||
|
- http-check send meth GET uri /
|
||||||
|
- server srv_nginx1 172.17.0.3:80 check inter 5s
|
||||||
|
- server srv_nginx2 172.17.0.2:80 check inter 5s
|
||||||
|
|
||||||
|
# listen configuration blocks
|
||||||
|
# the default values expose a monitoring listener on all interfaces on port 9000
|
||||||
|
# /stats returns the haproxy dashboard (please change the user and password in the configuration)
|
||||||
|
# /health returns a 200 OK response as long as haproxy is alive and well
|
||||||
|
# /metrics returns prometheus metrics for the haproxy instance
|
||||||
|
deploy_haproxy_listen:
|
||||||
|
- name: monitoring
|
||||||
|
options:
|
||||||
|
- bind :9000
|
||||||
|
- mode http
|
||||||
|
- option httpchk
|
||||||
|
- stats enable
|
||||||
|
- stats uri /stats
|
||||||
|
- stats refresh 30s
|
||||||
|
- stats show-desc
|
||||||
|
- stats show-legends
|
||||||
|
- stats auth admin:password
|
||||||
|
- http-check send meth GET uri /health ver HTTP/1.1 hdr Host localhost
|
||||||
|
- http-check expect status 200
|
||||||
|
- acl health_check_ok nbsrv() ge 1
|
||||||
|
- monitor-uri /health
|
||||||
|
- http-request use-service prometheus-exporter if { path /metrics }
|
10
molecule/default_vagrant/prepare.yml
Normal file
10
molecule/default_vagrant/prepare.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include ednxzu.install_docker"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: ednxzu.install_docker
|
||||||
|
vars:
|
||||||
|
install_docker_python_packages: true
|
6
molecule/default_vagrant/requirements.yml
Normal file
6
molecule/default_vagrant/requirements.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# requirements file for molecule
|
||||||
|
roles:
|
||||||
|
- name: ednxzu.manage_repositories
|
||||||
|
- name: ednxzu.manage_apt_packages
|
||||||
|
- name: ednxzu.install_docker
|
@ -2,18 +2,18 @@
|
|||||||
# task/install_docker file for deploy_haproxy
|
# task/install_docker file for deploy_haproxy
|
||||||
- name: "Update container volume list"
|
- name: "Update container volume list"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
hashi_consul_container_volume_map: "{{ hashi_consul_container_volume_map + hashi_consul_extra_container_volumes }}"
|
deploy_haproxy_container_volume_map: "{{ deploy_haproxy_container_volume_map + deploy_haproxy_extra_container_volumes }}"
|
||||||
|
|
||||||
- name: "Include ednxzu.docker_systemd_service"
|
- name: "Include ednxzu.docker_systemd_service"
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: ednxzu.docker_systemd_service
|
name: ednxzu.docker_systemd_service
|
||||||
vars:
|
vars:
|
||||||
docker_systemd_service_container_name: "consul"
|
docker_systemd_service_container_name: "haproxy"
|
||||||
docker_systemd_service_image: "{{ hashi_consul_docker_image }}:{{ hashi_consul_version }}"
|
docker_systemd_service_image: "{{ deploy_haproxy_docker_image }}:{{ deploy_haproxy_version }}"
|
||||||
docker_systemd_service_container_env: "{{ hashi_consul_env_variables }}"
|
docker_systemd_service_container_env: "{{ deploy_haproxy_env_variables }}"
|
||||||
docker_systemd_service_flags:
|
docker_systemd_service_flags:
|
||||||
- network: host
|
- network: host
|
||||||
- volume: "{{ hashi_consul_container_volume_map }}"
|
- volume: "{{ deploy_haproxy_container_volume_map }}"
|
||||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||||
docker_systemd_service_state: "{{ 'started' if hashi_consul_start_service else 'stopped'}}"
|
docker_systemd_service_state: "{{ 'started' if deploy_haproxy_start_service else 'stopped'}}"
|
||||||
docker_systemd_service_restart: "{{ true if hashi_consul_start_service else false}}"
|
docker_systemd_service_restart: "{{ true if deploy_haproxy_start_service else false}}"
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
- name: "Import install_host.yml"
|
- name: "Import install_host.yml"
|
||||||
ansible.builtin.include_tasks: install_host.yml
|
ansible.builtin.include_tasks: install_host.yml
|
||||||
|
when: deploy_haproxy_deploy_method == 'host'
|
||||||
|
|
||||||
- name: "Import configure.yml"
|
- name: "Import configure.yml"
|
||||||
ansible.builtin.include_tasks: configure.yml
|
ansible.builtin.include_tasks: configure.yml
|
||||||
|
|
||||||
|
- name: "Import install_docker.yml"
|
||||||
|
ansible.builtin.include_tasks: "install_docker.yml"
|
||||||
|
when: deploy_haproxy_deploy_method == 'docker'
|
||||||
|
|
||||||
|
- name: "Flush handlers"
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
deploy_haproxy_config_dir: /etc/haproxy
|
deploy_haproxy_config_dir: /etc/haproxy
|
||||||
deploy_haproxy_socket: /var/lib/haproxy/stats
|
deploy_haproxy_socket: /var/lib/haproxy/stats
|
||||||
deploy_haproxy_chroot: /var/lib/haproxy
|
deploy_haproxy_chroot: /var/lib/haproxy
|
||||||
deploy_haproxy_user: haproxy
|
deploy_haproxy_user: "{{ '99' if deploy_haproxy_deploy_method == 'docker' else 'haproxy' }}"
|
||||||
deploy_haproxy_group: haproxy
|
deploy_haproxy_group: "{{ '99' if deploy_haproxy_deploy_method == 'docker' else 'haproxy' }}"
|
||||||
deploy_haproxy_service_name: "haproxy{{ '_container' if deploy_haproxy_deploy_method == 'docker' }}"
|
deploy_haproxy_service_name: "haproxy{{ '_container' if deploy_haproxy_deploy_method == 'docker' }}"
|
||||||
deploy_haproxy_docker_image: haproxy
|
deploy_haproxy_docker_image: haproxytech/haproxy-debian
|
||||||
deploy_haproxy_version_map:
|
deploy_haproxy_version_map:
|
||||||
latest: "2.9"
|
latest: "2.9"
|
||||||
|
deploy_haproxy_container_volume_map:
|
||||||
|
- "{{ deploy_haproxy_config_dir }}:/usr/local/etc/haproxy"
|
||||||
|
# - "{{ deploy_haproxy_chroot }}:{{ deploy_haproxy_chroot }}"
|
||||||
|
|
||||||
deploy_haproxy_repository:
|
deploy_haproxy_repository:
|
||||||
debian:
|
debian:
|
||||||
|
Loading…
Reference in New Issue
Block a user