| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- ---
- - name: Ensure HAProxy is deployed
- hosts: servera.lab.example.com
- gather_facts: false
- become: true
- tasks:
- - name: the haproxy package is installed
- yum:
- name: haproxy
- state: present
- - name: the /etc/pki/haproxy directory exists
- file:
- path: /etc/pki/haproxy
- state: directory
- owner: root
- mode: '700'
- - name: the SSL file for HTTPS termination is deployed
- copy:
- # You need to create that file from the
- # servera.lab.example.com.{crt,key} files under the
- # files/ directory
- src: files/haproxy.pem
- dest: /etc/pki/haproxy/haproxy.pem
- notify: restart haproxy
- - name: the HAProxy configuration file is deployed
- copy:
- # You need to complete that configuration file
- src: files/haproxy.cfg
- dest: /etc/haproxy/haproxy.cfg
- notify: restart haproxy
- - name: the haproxy service is started and enabled
- service:
- name: haproxy
- state: started
- enabled: yes
- - name: the http and https firewall services are opened
- firewalld:
- service: "{{ item }}"
- state: enabled
- immediate: yes
- permanent: yes
- loop:
- - http
- - https
- handlers:
- - name: restart haproxy
- service:
- name: haproxy
- state: restarted
|