nginx/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 09 Feb 2020 12:08:03 -0600
changeset 93 976670b2ca63
parent 92 roles/nginx/tasks/main.yaml@d4924111ce28
permissions -rw-r--r--
Moved roles to top level dir.

---

- name: install nginx packages
  become: yes
  apt: name="nginx"

- name: install site
  become: yes
  template: src="{{nginx_conf_src}}" dest="/etc/nginx/sites-available/{{nginx_conf_dst}}"
  notify: restart nginx

- name: install nginx packages
  become: yes
  apt: name="python-certbot-nginx"
  notify: restart nginx
  when: nginx_enable_certbot

- name: install certbot in nginx
  become: yes
  command: "certbot certonly --nginx -n --agree-tos -d {{nginx_server_name}} -m {{nginx_admin_email}}"
  changed_when: false
  when: nginx_enable_certbot

- name: disable default site
  become: yes
  file: path="/etc/nginx/sites-enabled/default" state="absent"
  notify: restart nginx

- name: enable site
  become: yes
  file:
    src:  "/etc/nginx/sites-available/{{nginx_conf_dst}}"
    dest: "/etc/nginx/sites-enabled/{{nginx_conf_dst}}"
    state: "link"
  notify: restart nginx

- name: enable nginx service
  become: yes
  systemd: name="nginx" enabled="yes" state="started"