aboutsummaryrefslogtreecommitdiff
path: root/roles/nginx/tasks/main.yaml
blob: 91fd8a59fd22338e167e431a5bcf73a2a276e3a2 (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
58
59
60
61
62
63
64
65
66
67
# References
# https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-debian-10

---

- name: 'Install nginx'
  apt:
    name:
      - 'nginx'
    state: 'present'
    update_cache: true
  notify:
    - 'nginx_restart'

- name: 'Copy the http nginx.conf files'
  template:
    src: 'http.nginx.conf.j2'
    dest: '/etc/nginx/sites-available/{{ item }}'
    mode: '644'
  loop:
    - 'default'
    - 'kumardamani.xyz'
    - 'amayastuff.com'
  register: '_config_copy'
  notify:
    - 'nginx_restart'

- name: 'Remove the old symbolic link'
  file:
    path: '/etc/nginx/sites-enabled/{{ item }}'
    state: 'absent'
  loop: '{{ nginx_website_domains }}'

- name: 'Create a http symbolic link'
  file:
    src: '/etc/nginx/sites-available/{{ item }}'
    dest: '/etc/nginx/sites-enabled/{{ item }}'
    state: 'link'
  loop: '{{ nginx_website_domains }}'

- name: 'Check nginx config'  # noqa no-changed-when
  command: 'nginx -t'

- name: 'Copy the http nginx.conf for apps'
  template:
    src: 'app.nginx.conf.j2'
    dest: '/etc/nginx/sites-available/{{ item.app }}'
    mode: '644'
  loop: '{{ nginx_apps_confs }}'
  notify:
    - 'nginx_restart'

- name: 'Remove the old symbolic link for apps'
  file:
    path: '/etc/nginx/sites-enabled/{{ item.app }}'
    state: 'absent'
  loop: '{{ nginx_apps_confs }}'

- name: 'Create a http symbolic link for apps'
  file:
    src: '/etc/nginx/sites-available/{{ item.app }}'
    dest: '/etc/nginx/sites-enabled/{{ item.app }}'
    state: 'link'
  loop: '{{ nginx_apps_confs }}'

- name: 'Check nginx config'  # noqa no-changed-when
  command: 'nginx -t'