homelab/roles/nginx/tasks/main.yml

37 lines
983 B
YAML
Raw Normal View History

2021-04-26 20:35:59 +00:00
- name: ensure directories exist
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ nginx_confd_folder }}"
2021-05-05 18:41:28 +00:00
- name: generate and install self-signed certs
import_tasks: self-signed.yml
when: self_signed
- name: create nginx bridge network
docker_network:
name: nginx-internal
attachable: true
internal: true
state: present
2021-04-26 20:35:59 +00:00
- name: run container
docker_container:
name: 'nginx'
image: nginx
networks:
- name: bridge
- name: nginx-internal
volumes:
2021-04-26 20:35:59 +00:00
- "{{ data_folder }}/nginx/nginx.conf:/etc/nginx/nginx.conf"
2021-04-27 17:13:35 +00:00
- "{{ data_folder }}/nginx/{{ base_domain }}.key:/etc/nginx/{{ base_domain }}.key"
- "{{ data_folder }}/nginx/{{ base_domain }}.crt:/etc/nginx/{{ base_domain }}.crt"
- "{{ nginx_confd_folder }}:/etc/nginx/conf.d"
ports:
- "80:80"
2021-04-26 21:54:10 +00:00
- "443:443"
env:
NGINX_HOST: "{{ base_domain }}"
NGINX_PORT: '80'
state: started
restart: yes