nginx/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Tue, 09 Jun 2020 19:21:46 -0500
changeset 40 b42b417751e5
child 47 3f1771bb0d79
permissions -rw-r--r--
Moved over postgresql and nginx roles from pleroma roles.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: install nginx packages
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
  apt: name="nginx"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
- name: install site
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
  template: src="{{nginx_conf_src}}" dest="/etc/nginx/sites-available/{{nginx_conf_dst}}"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
  notify: restart nginx
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
- name: install nginx packages
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
  apt: name="python-certbot-nginx"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
  notify: restart nginx
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
  when: nginx_enable_certbot
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    17
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
- name: install certbot in nginx
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
  command: "certbot certonly --nginx -n --agree-tos -d {{nginx_server_name}} -m {{nginx_admin_email}}"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
  changed_when: false
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
  when: nginx_enable_certbot
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    23
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    24
- name: disable default site
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    25
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    26
  file: path="/etc/nginx/sites-enabled/default" state="absent"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    27
  notify: restart nginx
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    28
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
- name: enable site
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    31
  file:
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
    src:  "/etc/nginx/sites-available/{{nginx_conf_dst}}"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
    dest: "/etc/nginx/sites-enabled/{{nginx_conf_dst}}"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
    state: "link"
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
  notify: restart nginx
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
- name: enable nginx service
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
  become: yes
b42b417751e5 Moved over postgresql and nginx roles from pleroma roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
  systemd: name="nginx" enabled="yes" state="started"