Configuring Haproxy by Ansible

Haproxy

Road map of Ansible role of Haproxy

  1. Make an inventory that contains the webserver’s ip
  2. Edit the config file by jinja template
  3. Now install the haproxy software
  4. Start the service
  5. Copy the config files
  6. Restart the service
- name: installing haproxy
package:
name: haproxy
state: present
- name: starting services
service:
name: haproxy
state: started
- name: copying files
template:
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
notify: restart
- hosts: webserver
gather_facts: no
tasks:
- name: setting up webservers
include_role:
name: http
- hosts: loadbalancer
gather_facts: no
tasks:
- name: setting up load balancer

Output

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store