nginx/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 07 Oct 2024 23:31:51 -0500
changeset 239 c3e3169399a8
parent 238 bdbc88cb5078
permissions -rw-r--r--
Updated java version and disabled geyser due to too old jde.

---

- name: apt install nginx
  become: yes
  apt: name="{{item}}"
  loop:
    - "nginx"
    - "libnginx-mod-stream"
  notify: restart nginx

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

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

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

- name: make config available
  become: yes
  template:
    src:  "{{nginx_conf_src}}"
    dest: "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
  notify: reload 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: reload nginx

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

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