main.yml 893 B

1234567891011121314151617181920212223242526272829303132
  1. ---
  2. - name: Enable nginx repo (RedHat).
  3. copy: >
  4. src=nginx.repo
  5. dest=/etc/yum.repos.d/nginx.repo
  6. owner=root group=root mode=644
  7. when: ansible_os_family == 'RedHat'
  8. - name: Ensure nginx is installed (RedHat).
  9. yum: pkg=nginx state=installed enablerepo=nginx
  10. when: ansible_os_family == 'RedHat'
  11. - name: Ensure nginx is installed (Debian).
  12. apt: pkg=nginx state=installed
  13. when: ansible_os_family == 'Debian'
  14. - name: Copy nginx configuration in place.
  15. template: >
  16. src=nginx.conf.j2
  17. dest=/etc/nginx/nginx.conf
  18. owner=root group=root mode=644
  19. notify: restart nginx
  20. - name: Ensure nginx is started and enabled to start at boot.
  21. service: name=nginx state=started enabled=yes
  22. - name: Remove default nginx config file (if configured).
  23. file: >
  24. path={{ nginx_default_vhost_path }}
  25. state=absent
  26. when: nginx_remove_default_vhost
  27. notify: restart nginx