main.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. ---
  2. # Ensures that HAProxy on target host only allows port 443.
  3. #
  4. # XXX: This role is completely ROL-specific and requires HAProxy already
  5. # deployed on the target host, using a very specific config file format.
  6. #
  7. - name: Ensure the entire insecure frontend section is commented out.
  8. become: yes
  9. ansible.builtin.replace:
  10. path: /etc/haproxy/haproxy.cfg
  11. after: "# round robin balancing for OCP4 Ingress Insecure Port"
  12. before: "# round robin balancing for OCP4 Ingress Secure Port"
  13. regexp: "^([^#])"
  14. replace: "#\\g<1>"
  15. notify:
  16. - restart haproxy
  17. - name: Ensure there is a redirect block for incoming requests on 80.
  18. become: yes
  19. ansible.builtin.blockinfile:
  20. path: /etc/haproxy/haproxy.cfg
  21. marker: "# {mark} FRONTEND REDIRECT FOR INSECURE HTTP"
  22. marker_begin: "START"
  23. marker_end: "END"
  24. insertafter: EOF
  25. block: |
  26. frontend ingress_insecure_redirect
  27. bind 192.168.50.254:80
  28. mode http
  29. http-request redirect scheme https code 301 unless { ssl_fc }
  30. notify:
  31. - restart haproxy
  32. ...