Playbooks to a new Lilik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.5 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. ---
  2. - include_role:
  3. name: service
  4. # static: yes # see static include issue: https://github.com/ansible/ansible/issues/13485
  5. vars:
  6. service_name: nginx
  7. service_packages:
  8. - nginx
  9. - name: disable nginx default configuration
  10. file:
  11. path: /etc/nginx/sites-enabled/default
  12. state: absent
  13. notify: restart nginx
  14. - name: install php-fpm
  15. apt:
  16. name: "{{ item }}"
  17. state: present
  18. update_cache: yes
  19. cache_valid_time: 3600
  20. with_items:
  21. - php-fpm
  22. when: php | bool
  23. notify:
  24. - restart nginx
  25. - name: add timezone to php.ini
  26. lineinfile:
  27. dest: /etc/php/7.0/fpm/php.ini
  28. regexp: '^;?date.timezone ='
  29. line: 'date.timezone = Europe/Berlin'
  30. when: php | bool
  31. notify:
  32. - restart nginx
  33. - name: create nginx location configuration directory
  34. file:
  35. path: '{{ item }}'
  36. state: directory
  37. mode: 0755
  38. owner: www-data
  39. group: www-data
  40. with_items:
  41. - /etc/nginx/locations/
  42. - '/etc/nginx/locations/{{ server_fqdn }}/'
  43. - name: upload nginx configuration
  44. template:
  45. src: base.j2
  46. dest: "/etc/nginx/sites-available/{{ server_fqdn }}.conf"
  47. notify:
  48. - restart nginx
  49. # - name: add nginx configurations
  50. # template:
  51. # src: "roles/{{ parent_role_path }}/templates/{{ item }}.conf.nginx.j2"
  52. # dest: /etc/nginx/sites-available/{{ item }}.conf
  53. # with_items: "{{ config_names }}"
  54. # notify:
  55. # - restart nginx
  56. # - name: add proxy to config_names
  57. # set_fact:
  58. # config_names: "{{ config_names | union( [config_name])}}"
  59. # when: is_proxy | bool
  60. - name: create Diffie Hellman exchange parameters
  61. command: openssl dhparam -out /etc/nginx/dhparam.pem 2048
  62. args:
  63. creates: /etc/nginx/dhparam.pem
  64. notify: restart nginx
  65. - name: enable nginx configurations
  66. file:
  67. src: "/etc/nginx/sites-available/{{ server_fqdn }}.conf"
  68. dest: "/etc/nginx/sites-enabled/{{ server_fqdn }}.conf"
  69. state: link
  70. # with_items: "{{ config_names }}"
  71. notify: restart nginx
  72. - name: upload nginx location configuration from parent role
  73. template:
  74. src: "roles/{{ parent_role_path }}/templates/{{ config_name }}.conf.nginx.j2"
  75. dest: "/etc/nginx/locations/{{ server_fqdn }}/{{ config_name }}.conf"
  76. notify:
  77. - restart nginx
  78. when: 'config_name is not none'
  79. - name: upload nginx location configuration for proxy
  80. template:
  81. src: proxy.conf.nginx.j2
  82. dest: "/etc/nginx/locations/{{ server_fqdn }}/{{ parent_role_path or 'proxy' }}.conf"
  83. notify:
  84. - restart nginx
  85. when: 'is_proxy'