main.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. - name: Install haproxy
  3. package: name=haproxy state=present
  4. when: not openshift.common.is_containerized | bool
  5. - name: Pull haproxy image
  6. command: >
  7. docker pull {{ openshift.common.router_image }}:{{ openshift_image_tag }}
  8. when: openshift.common.is_containerized | bool
  9. - name: Create config directory for haproxy
  10. file:
  11. path: /etc/haproxy
  12. state: directory
  13. when: openshift.common.is_containerized | bool
  14. - name: Create the systemd unit files
  15. template:
  16. src: "haproxy.docker.service.j2"
  17. dest: "/etc/systemd/system/haproxy.service"
  18. when: openshift.common.is_containerized | bool
  19. notify: restart haproxy
  20. - name: Configure systemd service directory for haproxy
  21. file:
  22. path: /etc/systemd/system/haproxy.service.d
  23. state: directory
  24. when: not openshift.common.is_containerized | bool
  25. # Work around ini_file create option in 2.2 which defaults to no
  26. - name: Create limits.conf file
  27. file:
  28. dest: /etc/systemd/system/haproxy.service.d/limits.conf
  29. state: touch
  30. mode: 0660
  31. owner: root
  32. group: root
  33. changed_when: false
  34. when: not openshift.common.is_containerized | bool
  35. - name: Configure the nofile limits for haproxy
  36. ini_file:
  37. dest: /etc/systemd/system/haproxy.service.d/limits.conf
  38. section: Service
  39. option: LimitNOFILE
  40. value: "{{ openshift_loadbalancer_limit_nofile | default(100000) }}"
  41. notify: restart haproxy
  42. when: not openshift.common.is_containerized | bool
  43. - name: Configure haproxy
  44. template:
  45. src: haproxy.cfg.j2
  46. dest: /etc/haproxy/haproxy.cfg
  47. owner: root
  48. group: root
  49. mode: 0644
  50. notify: restart haproxy
  51. - name: Enable and start haproxy
  52. systemd:
  53. name: haproxy
  54. state: started
  55. enabled: yes
  56. daemon_reload: yes
  57. register: start_result
  58. - set_fact:
  59. haproxy_start_result_changed: "{{ start_result | changed }}"