configuration.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ---
  2. - name: Create the directories for site specific configurations
  3. file: path={{nginx_conf_dir}}/{{ item }} state=directory owner=root group={{nginx_group}} mode=0755
  4. with_items:
  5. - "sites-available"
  6. - "sites-enabled"
  7. - "auth_basic"
  8. - "conf.d"
  9. tags: [configuration,nginx]
  10. - name: Ensure log directory exist
  11. file: path={{ nginx_log_dir }} state=directory owner={{nginx_user}} group={{nginx_group}} mode=0755
  12. tags: [configuration,nginx]
  13. - name: Copy the nginx configuration file
  14. template: src=nginx.conf.j2 dest={{nginx_conf_dir}}/nginx.conf
  15. notify:
  16. - restart nginx
  17. tags: [configuration,nginx]
  18. - name: Ensure auth_basic files created
  19. template: src=auth_basic.j2 dest={{nginx_conf_dir}}/auth_basic/{{ item }} owner=root group={{nginx_group}} mode=0750
  20. with_items: nginx_auth_basic_files.keys()
  21. tags: [configuration,nginx]
  22. - name: Create the configurations for sites
  23. template: src=site.conf.j2 dest={{nginx_conf_dir}}/sites-available/{{ item }}.conf
  24. with_items: nginx_sites.keys()
  25. notify:
  26. - restart nginx
  27. tags: [configuration,nginx]
  28. - name: Create links for sites-enabled
  29. file: state=link src={{nginx_conf_dir}}/sites-available/{{ item }}.conf dest={{nginx_conf_dir}}/sites-enabled/{{ item }}.conf
  30. with_items: nginx_sites.keys()
  31. notify:
  32. - reload nginx
  33. tags: [configuration,nginx]
  34. - name: Create the configurations for independent config file
  35. template: src=config.conf.j2 dest={{nginx_conf_dir}}/conf.d/{{ item }}.conf
  36. with_items: nginx_configs.keys()
  37. notify:
  38. - reload nginx
  39. tags: [configuration,nginx]
  40. - name: Check nginx syntax of configuration files
  41. shell: "{{ nginx_binary_name }} -t"
  42. register: result
  43. changed_when: "result.rc != 0"
  44. always_run: yes
  45. when: nginx_installation_type in nginx_installation_types_using_service
  46. tags: [configuration,nginx]