deploy_varnish.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. - name: Ensure Varnish is deployed
  3. hosts: serverb.lab.example.com
  4. gather_facts: false
  5. become: true
  6. tasks:
  7. - name: the varnish package is installed
  8. yum:
  9. name: varnish
  10. state: present
  11. - name: the systemd drop-in directory exists
  12. file:
  13. path: /etc/systemd/system/varnish.service.d
  14. state: directory
  15. - name: the varnish systemd service configuration file is deployed
  16. copy:
  17. # You need to create that configuration file
  18. src: files/port.conf
  19. dest: /etc/systemd/system/varnish.service.d/port.conf
  20. notify:
  21. - reload systemd
  22. - restart varnish
  23. - name: the Varnish configuration file is deployed
  24. copy:
  25. # You need to complete that configuration file
  26. src: files/default.vcl
  27. dest: /etc/varnish/default.vcl
  28. notify: restart varnish
  29. - name: the varnish service is started and enabled
  30. service:
  31. name: varnish
  32. state: started
  33. enabled: yes
  34. - name: the port 9000 is opened in the firewall
  35. firewalld:
  36. port: 9000/tcp
  37. state: enabled
  38. immediate: yes
  39. permanent: yes
  40. handlers:
  41. - name: reload systemd
  42. systemd:
  43. daemon_reload: yes
  44. - name: restart varnish
  45. service:
  46. name: varnish
  47. state: restarted