nginx.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. # tasks file for ffdo.mapserver-nginx
  3. - name: Ensure nginx is installed
  4. apt: name=nginx state=present update_cache=yes cache_valid_time=3600
  5. - name: Install openssl to generate DH params
  6. apt: name=openssl state=present
  7. - name: Ensure nginx ssl directory exists
  8. file: dest=/etc/nginx/ssl/ state=directory
  9. - name: Create private ssl key from secret var
  10. copy: content="{{ mapserver_ssl_private_key }}" dest="{{mapserver_ssl_key_path}}"
  11. notify:
  12. - Restart nginx
  13. - name: Create nginx server certificate from secret var
  14. copy: content="{{ mapserver_ssl_server_cert }}" dest="{{mapserver_ssl_cert_path}}"
  15. notify:
  16. - Restart nginx
  17. - name: Deploy pregenerated DH params
  18. when: mapserver_use_pregenerated_dh_params
  19. copy: content="{{mapserver_dh_params}}" dest=/etc/nginx/dhparams.pem
  20. notify:
  21. - Restart nginx
  22. - name: Generate strong dhparams
  23. when: not mapserver_use_pregenerated_dh_params
  24. shell: openssl dhparam -out /etc/nginx/dhparams.pem 4096
  25. args:
  26. creates: /etc/nginx/dhparams.pem
  27. notify:
  28. - Restart nginx
  29. - name: Install nginx configs
  30. template:
  31. src: "{{item.src}}"
  32. dest: "{{item.dest}}"
  33. with_items:
  34. - src: nginx-default.conf.j2
  35. dest: /etc/nginx/sites-available/default
  36. notify:
  37. - Restart nginx
  38. - name: Activate nginx configurations
  39. file:
  40. src: /etc/nginx/sites-available/default
  41. dest: /etc/nginx/sites-enabled/default
  42. state: link
  43. - name: Ensure nginx is started and enabled
  44. service: name=nginx state=started enabled=yes