deploy_haproxy.yml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. copy:
  19. # You need to create that file from the
  20. # servera.lab.example.com.{crt,key} files under the
  21. # files/ directory
  22. src: files/haproxy.pem
  23. dest: /etc/pki/haproxy/haproxy.pem
  24. notify: restart haproxy
  25. - name: the HAProxy configuration file is deployed
  26. copy:
  27. # You need to complete that configuration file
  28. src: files/haproxy.cfg
  29. dest: /etc/haproxy/haproxy.cfg
  30. notify: restart haproxy
  31. - name: the haproxy service is started and enabled
  32. service:
  33. name: haproxy
  34. state: started
  35. enabled: yes
  36. - name: the http and https firewall services are opened
  37. firewalld:
  38. service: "{{ item }}"
  39. state: enabled
  40. immediate: yes
  41. permanent: yes
  42. loop:
  43. - http
  44. - https
  45. handlers:
  46. - name: restart haproxy
  47. service:
  48. name: haproxy
  49. state: restarted