main.yml 716 B

123456789101112131415161718192021222324
  1. ---
  2. - name: Enable nginx repo.
  3. copy: src=nginx.repo dest=/etc/yum.repos.d/nginx.repo owner=root group=root mode=644
  4. when: ansible_os_family == 'RedHat'
  5. - name: Ensure nginx is installed.
  6. yum: pkg=nginx state=installed enablerepo=nginx
  7. when: ansible_os_family == 'RedHat'
  8. - name: Ensure nginx is installed.
  9. apt: pkg=nginx state=installed update_cache=true
  10. notify:
  11. - restart nginx
  12. when: ansible_os_family == 'Debian'
  13. - name: Copy nginx configuration in place.
  14. template: >
  15. src=nginx.conf.j2
  16. dest=/etc/nginx/nginx.conf
  17. owner=root group=root mode=644
  18. notify: restart nginx
  19. - name: Ensure nginx is started and enabled to start at boot.
  20. service: name=nginx state=started enabled=yes