first commit
This commit is contained in:
19
solutions/roles/balancer/MANIFEST.json
Normal file
19
solutions/roles/balancer/MANIFEST.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"collection_info": null,
|
||||
"dependencies": [],
|
||||
"format": 1,
|
||||
"license": "MIT",
|
||||
"license_file": null,
|
||||
"name": "balancer",
|
||||
"namespace": "local",
|
||||
"readme": "README.md",
|
||||
"repository": null,
|
||||
"tags": [
|
||||
"haproxy",
|
||||
"loadbalancer",
|
||||
"networking",
|
||||
"web"
|
||||
],
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
||||
11
solutions/roles/balancer/defaults/main.yml
Normal file
11
solutions/roles/balancer/defaults/main.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
haproxy_frontend_port: 80
|
||||
|
||||
haproxy_backend_servers:
|
||||
- name: node3
|
||||
address: node3
|
||||
port: 80
|
||||
- name: node4
|
||||
address: node4
|
||||
port: 80
|
||||
|
||||
6
solutions/roles/balancer/handlers/main.yml
Normal file
6
solutions/roles/balancer/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Restart haproxy
|
||||
ansible.builtin.service:
|
||||
name: haproxy
|
||||
state: restarted
|
||||
|
||||
2
solutions/roles/balancer/meta/.galaxy_install_info
Normal file
2
solutions/roles/balancer/meta/.galaxy_install_info
Normal file
@@ -0,0 +1,2 @@
|
||||
install_date: 'Tue 30 Dec 2025 12:53:11 AM '
|
||||
version: ''
|
||||
21
solutions/roles/balancer/meta/main.yml
Normal file
21
solutions/roles/balancer/meta/main.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
galaxy_info:
|
||||
role_name: balancer
|
||||
author: lab
|
||||
description: Installs and configures HAProxy to load balance Apache servers
|
||||
license: MIT
|
||||
min_ansible_version: "2.9"
|
||||
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- "9"
|
||||
|
||||
galaxy_tags:
|
||||
- haproxy
|
||||
- loadbalancer
|
||||
- networking
|
||||
- web
|
||||
|
||||
dependencies: []
|
||||
|
||||
28
solutions/roles/balancer/tasks/main.yml
Normal file
28
solutions/roles/balancer/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Install HAProxy
|
||||
ansible.builtin.dnf:
|
||||
name: haproxy
|
||||
state: present
|
||||
|
||||
- name: Enable and start HAProxy
|
||||
ansible.builtin.service:
|
||||
name: haproxy
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Deploy HAProxy configuration
|
||||
ansible.builtin.template:
|
||||
src: haproxy.cfg.j2
|
||||
dest: /etc/haproxy/haproxy.cfg
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: Restart haproxy
|
||||
|
||||
- name: Allow port 80 through firewalld
|
||||
ansible.posix.firewalld:
|
||||
service: http
|
||||
permanent: true
|
||||
immediate: true
|
||||
state: enabled
|
||||
|
||||
25
solutions/roles/balancer/templates/haproxy.cfg.j2
Normal file
25
solutions/roles/balancer/templates/haproxy.cfg.j2
Normal file
@@ -0,0 +1,25 @@
|
||||
global
|
||||
log /dev/log local0
|
||||
log /dev/log local1 notice
|
||||
daemon
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 5s
|
||||
timeout client 50s
|
||||
timeout server 50s
|
||||
|
||||
frontend http_front
|
||||
bind *:80
|
||||
default_backend webservers
|
||||
|
||||
backend webservers
|
||||
balance roundrobin
|
||||
option httpchk
|
||||
server node3 node3:80 check
|
||||
server node4 node4:80 check
|
||||
|
||||
Reference in New Issue
Block a user