1. ---
  2. - hosts: localhost
  3. tasks:
  4. - name: ensure nginx is at the latest version
  5. apt: name=nginx state=latest
  6. become: yes
  7. - name: start nginx
  8. service:
  9. name: nginx
  10. state: started
  11. become: yes
  12. - name: copy the nginx config file and restart nginx
  13. copy:
  14. src: /home/foo/static_site.cfg
  15. dest: /etc/nginx/sites-available/static_site.cfg
  16. become: yes
  17. - name: create symlink
  18. file:
  19. src: /etc/nginx/sites-available/static_site.cfg
  20. dest: /etc/nginx/sites-enabled/default
  21. state: link
  22. become: yes
  23. - name: copy the content of the web site
  24. copy:
  25. src: /home/foo/static-site-src/
  26. dest: /home/foo/static-site
  27. - name: restart nginx
  28. service:
  29. name: nginx
  30. state: restarted
  31. become: yes