From 968643a4cc5394be39db4f7e2f70250c855108aa Mon Sep 17 00:00:00 2001 From: Michael Buluma Date: Sat, 18 Nov 2023 10:34:56 +0300 Subject: [PATCH] use new container. --- .ansible-lint | 1 + .github/settings.yml | 2 +- .github/workflows/molecule.yml | 4 ++- .gitlab-ci.yml | 4 ++- README.md | 63 ++++++++++++++++++++++++++++++++-- 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 937b336..fa67b68 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -3,6 +3,7 @@ # Ansible managed # exclude_paths: + - meta/preferences.yml - molecule/default/prepare.yml - molecule/default/converge.yml - molecule/default/verify.yml diff --git a/.github/settings.yml b/.github/settings.yml index 1f9f353..efdcb52 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -5,4 +5,4 @@ repository: description: Install and configure haproxy on your system. homepage: https://buluma.github.io/ - topics: cloud, haproxy, ansible, molecule, tox, playbook + topics: cloud, haproxy, networking, ansible, molecule, tox, playbook diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index c8feb56..3a271dd 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -42,6 +42,8 @@ jobs: config: - image: "enterpriselinux" tag: "8" + - image: "enterpriselinux" + tag: "latest" - image: "debian-systemd" tag: "latest" - image: "debian-systemd" @@ -70,7 +72,7 @@ jobs: - name: parse apparmor for mysql run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - name: molecule - uses: buluma/molecule-action@v5.0.9 + uses: buluma/molecule-action@v5.1.1 with: image: ${{ matrix.config.image }} tag: ${{ matrix.config.tag }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b52be1..1c3bb25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ --- -image: "buluma/github-action-molecule:5.0.9" +image: "buluma/github-action-molecule:5.1.1" variables: PY_COLORS: 1 @@ -14,6 +14,8 @@ molecule: matrix: - image: "enterpriselinux" tag: "8" + - image: "enterpriselinux" + tag: "latest" - image: "debian-systemd" tag: "latest" - image: "debian-systemd" diff --git a/README.md b/README.md index 9d4d966..b4a2ed3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,13 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/ haproxy_backends: - name: backend httpcheck: yes + # You can tell how the health check must be done. + # This requires haproxy version 2 + # http_check: + # send: + # method: GET + # uri: /health.html + # expect: status 200 balance: roundrobin # You can refer to hosts in an Ansible group. # The `ansible_default_ipv4` will be used as an address to connect to. @@ -48,8 +55,8 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/ options: - check - name: smtp - httpcheck: yes - balance: roundrobin + balance: leastconn + mode: tcp # You can also refer to a list of servers. servers: - name: first @@ -59,8 +66,30 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/ address: "127.0.0.2" port: 25 port: 25 + - name: vault + mode: tcp + httpcheck: GET /v1/sys/health HTTP/1.1 + servers: "{{ groups['all'] }}" + http_send_name_header: Host + port: 8200 options: - check + - check-ssl + - ssl verify none + + haproxy_listen_default_balance: roundrobin + haproxy_listens: + - name: listen + address: "*" + httpcheck: yes + listen_port: 8081 + balance: roundrobin + # You can refer to hosts in an Ansible group. + # The `ansible_default_ipv4` will be used as an address to connect to. + servers: "{{ groups['all'] }}" + port: 8080 + options: + - maxconn 100000 ``` The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/buluma/ansible-role-haproxy/blob/master/molecule/default/prepare.yml): @@ -86,6 +115,24 @@ The machine needs to be prepared. In CI this is done using [`molecule/default/pr # This role is applied to serve as a mock "backend" server. See `molecule/default/verify.yml`. - role: buluma.httpd httpd_port: 8080 + + vars: + _httpd_data_directory: + default: /var/www/html + Alpine: /var/www/localhost/htdocs + Suse: /srv/www/htdocs + + httpd_data_directory: "{{ _httpd_data_directory[ansible_os_family] | default(_httpd_data_directory['default'] ) }}" + post_tasks: + - name: Place health check + ansible.builtin.copy: + content: 'ok' + dest: "{{ httpd_data_directory }}/health.html" + + - name: Place sample page + ansible.builtin.copy: + content: 'Hello world!' + dest: "{{ httpd_data_directory }}/index.html" ``` Also see a [full explanation and example](https://buluma.github.io/how-to-use-these-roles.html) on how to use these roles. @@ -101,6 +148,7 @@ The default values for the variables are set in [`defaults/main.yml`](https://gi # Configure stats in HAProxy? haproxy_stats: yes haproxy_stats_port: 1936 +haproxy_stats_bind_addr: "0.0.0.0" # Default setttings for HAProxy. haproxy_retries: 3 @@ -111,6 +159,15 @@ haproxy_timeout_server: 1m haproxy_timeout_http_keep_alive: 10s haproxy_timeout_check: 10s haproxy_maxconn: 3000 + +# A list of frontends. See `molecule/ +haproxy_frontends: [] +haproxy_backend_default_balance: roundrobin +haproxy_backends: [] + +# For the listening lists: +haproxy_listen_default_balance: roundrobin +haproxy_listens: [] ``` ## [Requirements](#requirements) @@ -145,7 +202,7 @@ This role has been tested on these [container images](https://hub.docker.com/u/b |container|tags| |---------|----| -|[EL](https://hub.docker.com/repository/docker/buluma/enterpriselinux/general)|8| +|[EL](https://hub.docker.com/repository/docker/buluma/enterpriselinux/general)|8, 9| |[Debian](https://hub.docker.com/repository/docker/buluma/debian/general)|all| |[Fedora](https://hub.docker.com/repository/docker/buluma/fedora/general)|all| |[opensuse](https://hub.docker.com/repository/docker/buluma/opensuse/general)|all|