main_with_haproxy.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ---
  2. - name: Install software
  3. package:
  4. name: "{{ item }}"
  5. state: latest
  6. with_items: "{{ worker_packages }}"
  7. - name: Apache2 enable modules
  8. apache2_module:
  9. name: "{{ item }}"
  10. state: present
  11. with_items: "{{ worker_a2mods }}"
  12. notify: Restart Apache2
  13. - name: Apache2 disable sites
  14. file:
  15. path: "/etc/apache2/sites-enabled/{{ item }}"
  16. state: absent
  17. with_items: "{{ worker_a2dissites }}"
  18. notify: Restart Apache2
  19. - name: Apache2 create vhosts
  20. template:
  21. dest: "/etc/apache2/sites-available/{{ item }}"
  22. src: "etc/apache2/sites-available/{{ item }}.j2"
  23. mode: 0644
  24. backup: yes
  25. with_items: "{{ worker_a2ensites }}"
  26. notify: Restart Apache2
  27. - name: Apache2 enable sites
  28. file:
  29. path: "/etc/apache2/sites-enabled/{{ item }}"
  30. src: "/etc/apache2/sites-available/{{ item }}"
  31. state: link
  32. force: yes
  33. with_items: "{{ worker_a2ensites }}"
  34. notify: Restart Apache2
  35. - name: Apache2 create DocRoots
  36. file:
  37. path: "/{{ item }}"
  38. state: directory
  39. mode: 0755
  40. with_items: "{{ worker_a2docroots }}"
  41. notify: Restart Apache2
  42. - name: PHP Install pools
  43. template:
  44. dest: "/{{ item }}"
  45. src: "{{ item }}.j2"
  46. mode: 0644
  47. backup: yes
  48. with_items: "{{ worker_phpfpmpools }}"
  49. notify: Restart PHP-FPM
  50. - name: Disable worker in load balancers
  51. haproxy:
  52. socket: /run/haproxy/admin.sock
  53. backend: nodes
  54. host: "{{ inventory_hostname }}"
  55. state: disabled
  56. delegate_to: "{{ item }}"
  57. with_items: "{{ groups.lb }}"
  58. - name: Apache2 copy websites
  59. copy:
  60. dest: "/{{ item }}/"
  61. src: "{{ item }}/"
  62. backup: yes
  63. with_items: "{{ worker_a2docroots }}"
  64. - name: Apache2 template dummy index.html
  65. template:
  66. dest: "/{{ item }}/index.html"
  67. src: "{{ item }}/index.html.j2"
  68. mode: 0644
  69. backup: yes
  70. with_items: "{{ worker_a2docroots }}"
  71. - name: Sleep 30 seconds...
  72. pause: seconds=30
  73. - name: Enable worker in load balancers
  74. haproxy:
  75. socket: /run/haproxy/admin.sock
  76. backend: nodes
  77. host: "{{ inventory_hostname }}"
  78. state: enabled
  79. delegate_to: "{{ item }}"
  80. with_items: "{{ groups.lb }}"