homelab/roles/nginx/tasks/main.yml

27 lines
609 B
YAML

- name: ensure directories exist
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ nginx_confd_folder }}"
- name: copy .conf file
template:
src: nginx.conf.j2
dest: "{{ data_folder }}/nginx/nginx.conf"
mode: '0755'
- name: run container
docker_container:
name: 'nginx'
image: nginx
volumes:
- "{{ data_folder }}/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "{{ nginx_confd_folder }}:/etc/nginx/conf.d"
ports:
- "80:80"
env:
NGINX_HOST: "{{ base_domain }}"
NGINX_PORT: '80'
state: started
restart: yes