aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nginx/tasks/main.yml
blob: dda2c98da53b7ec790a7172350ed0cecb3ac5a4c (plain) (blame)
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

# nginx ~~ roles/nginx/tasks/main.yml
# Linux nginx webserver

---

- name: ensure role is run on linux hosts
  fail:
    msg: nginx role can only be run on linux host
  when: ansible_system != "Linux"

- name: ensure nginx is installed
  package: name=nginx state=present

- name: ensure nginx group exists
  group: name="{{ nginx_group }}" state=present

- name: ensure nginx user exists
  user: name="{{ nginx_user }}" group="{{ nginx_group }}" state=present

- name: generate nginx configuration
  template:
    src: nginx.conf.j2
    dest: /etc/nginx/nginx.conf
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0644

- name: ensure nginx sub-configuration directory exists
  file:
    path: "{{ nginx_subconf_dir }}"
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    state: directory
    mode: 0744

- name: enable and restart nginx
  service:
    name: nginx
    state: restarted
    enabled: true

remember that computers suck.