deploy_haproxy.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. - name: Ensure HAProxy is deployed
  3. hosts: servera.lab.example.com
  4. gather_facts: false
  5. become: true
  6. tasks:
  7. - name: the haproxy package is installed
  8. yum:
  9. name: haproxy
  10. state: present
  11. - name: the /etc/pki/haproxy directory exists
  12. file:
  13. path: /etc/pki/haproxy
  14. state: directory
  15. owner: root
  16. mode: '700'
  17. - name: the SSL file for HTTPS termination is deployed
  18. assemble:
  19. src: files
  20. remote_src: false
  21. regexp: "^servera\\.lab\\.example\\.com\\.(crt|key)$"
  22. dest: /etc/pki/haproxy/haproxy.pem
  23. notify: restart haproxy
  24. - name: the HAProxy configuration file is deployed
  25. copy:
  26. src: files/haproxy.cfg
  27. dest: /etc/haproxy/haproxy.cfg
  28. notify: restart haproxy
  29. - name: SELinux allows HAProxy to connect to remote port 6081
  30. seboolean:
  31. name: haproxy_connect_any
  32. state: true
  33. persistent: true
  34. - name: the haproxy service is started and enabled
  35. service:
  36. name: haproxy
  37. state: started
  38. enabled: yes
  39. - name: the https firewall service is opened
  40. firewalld:
  41. service: https
  42. state: enabled
  43. immediate: yes
  44. permanent: yes
  45. handlers:
  46. - name: restart haproxy
  47. service:
  48. name: haproxy
  49. state: restarted