summaryrefslogtreecommitdiffstats
path: root/roles/common-web/tasks/main.yml
blob: fb6bb2def0b4772ec3c70ec030aab036dd8be1e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- name: Install Nginx
  apt: pkg=nginx

- name: Limit Nginx logging
  lineinfile: "dest=/etc/logrotate.d/nginx create=yes
               regexp='^\\s*rotate\\s'
               line='\trotate 1'"
  tags:
    - logrotate

- name: Copy fastcgi parameters, acme-challenge and SSL configuration snippets
  copy: src=etc/nginx/snippets/{{ item }}
        dest=/etc/nginx/snippets/{{ item }}
        owner=root group=root
        mode=0644
  register: r1
  with_items:
    - fastcgi.conf
    - fastcgi-php.conf
    - fastcgi-php-ssl.conf
    - ssl.conf
    - acme-challenge.conf
  notify:
    - Restart Nginx

- name: Copy /etc/nginx/sites-available/default
  copy: src=etc/nginx/sites-available/default
        dest=/etc/nginx/sites-available/default
        owner=root group=root
        mode=0644
  register: r2
  notify:
    - Restart Nginx

- name: Create /etc/nginx/sites-enabled/default
  file: src=../sites-available/default
        dest=/etc/nginx/sites-enabled/default
        owner=root group=root
        state=link force=yes
  register: r3
  notify:
    - Restart Nginx

- name: Add .asc to text/plain MIME types
  lineinfile: dest=/etc/nginx/mime.types
              regexp='^(\s*text/plain\s+)'
              backrefs=yes
              line='\1txt asc;'
  register: r4
  notify:
    - Restart Nginx

- name: Start Nginx
  service: name=nginx state=started
  when: not (r1.changed or r2.changed or r3.changed or r4.changed)

- meta: flush_handlers