update_webcontent.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ---
  2. - name: Ensure new web content is deployed
  3. hosts: web_servers
  4. gather_facts: false
  5. become: true
  6. serial: 1
  7. tasks:
  8. - name: the web server is removed from service during the update
  9. haproxy:
  10. socket: /var/lib/haproxy/stats
  11. state: disabled
  12. backend: classroom-web-farm
  13. host: "{{ inventory_hostname }}"
  14. delegate_to: servera.lab.example.com
  15. - name: the new content is deployed
  16. synchronize:
  17. src: "new_web_content/{{ inventory_hostname }}/"
  18. dest: /var/www/html
  19. delete: true
  20. notify: Varnish Cache is clean
  21. post_tasks:
  22. - name: Smoke Test - Ensure HTTP 200 OK
  23. uri:
  24. url: "http://localhost"
  25. status_code: 200
  26. # If the test fails, servers are not re-enabled
  27. # in the load balancers, and the update process halts.
  28. - name: the healthy web server is enabled in HAProxy
  29. haproxy:
  30. socket: /var/lib/haproxy/stats
  31. state: enabled
  32. backend: classroom-web-farm
  33. host: "{{ inventory_hostname }}"
  34. delegate_to: servera.lab.example.com
  35. handlers:
  36. - name: Varnish Cache is clean
  37. service:
  38. name: varnish
  39. state: restarted