nginx/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 04 Jul 2020 13:20:11 -0500
changeset 115 1dc87d96ed8a
parent 47 3f1771bb0d79
child 118 56bffa9ef826
permissions -rw-r--r--
Added cooler cloaks.

---

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

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

- name: install base config
  become: yes
  copy: src="nginx.conf" dest="/etc/nginx/nginx.conf"
  notify: restart nginx

- name: make stream dirs
  become: yes
  file: path="/etc/nginx/streams-{{item}}" state="directory"
  loop: ["available", "enabled"]

- name: make config available
  become: yes
  template:
    src:  "{{nginx_conf_src}}"
    dest: "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
  notify: restart nginx

- name: enable config
  become: yes
  file:
    src:  "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
    dest: "/etc/nginx/{{nginx_server_type}}s-enabled/{{nginx_server_name}}.conf"
    state: "link"
  notify: restart nginx

- name: copy root files
  become: yes
  copy: src="{{nginx_root_src}}" dest="{{nginx_root_dest}}/"
  when: nginx_root
  notify: restart nginx

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