aboutsummaryrefslogtreecommitdiff
path: root/roles/nginx/tasks/main.yml
blob: f4ffb6c898ae43339fc379d25ca15ac2a4341a5b (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
---
- block:
    - name: Install nginx and required modules
      community.general.apk:
        name:
          - nginx
          - nginx-openrc
          - nginx-mod-http-xslt-filter
        state: present

    # permission are not right
    # - name: Ensure nginx web and log directories exist
    #   ansible.builtin.file:
    #     path: "{{ item }}"
    #     state: directory
    #     owner: nginx
    #     group: nginx
    #     mode: '0755'
    #   loop:
    #     - /srv/http
    #     - /var/log/nginx
    #     - /var/lib/nginx
    #     - /var/www/acme

    - name: Deploy main nginx.conf
      ansible.builtin.template:
        src: nginx.conf.j2
        dest: /etc/nginx/nginx.conf
        owner: root
        group: root
        mode: '0444'
        validate: nginx-validate %s /etc/nginx/nginx.conf
      notify: Reload nginx

    - name: Enable and start nginx service
      ansible.builtin.service:
        name: nginx
        enabled: true
        state: started

    - name: Install atomic nginx validation wrapper
      ansible.builtin.template:
        src: nginx-validate.j2
        dest: /usr/local/bin/nginx-validate
        owner: root
        group: root
        mode: '0755'

  tags:
    - nginx