diff --git a/ansible/playbooks/roles/nginx/tasks/docker_nginx.yaml b/ansible/playbooks/roles/nginx/tasks/docker_nginx.yaml index 835db15..c7e8050 100644 --- a/ansible/playbooks/roles/nginx/tasks/docker_nginx.yaml +++ b/ansible/playbooks/roles/nginx/tasks/docker_nginx.yaml @@ -7,7 +7,7 @@ - name: Create site dir file: - path: "statis_nginx_site" + path: "/home/{{ ansible_user }}/web/static_nginx_site" state: directory register: site_dir @@ -17,6 +17,19 @@ src: templates/index.html.j2 dest: "{{site_dir.path}}/index.html" + +- name: Create nginx conf dir + file: + path: "/home/{{ ansible_user }}/nginx/conf" + state: directory + register: nginx_conf_dir + +- name: Copy nginx config + template: + src: templates/nginx.conf.j2 + dest: "{{ nginx_conf_dir.path }}/nginx.conf" + + - name: Create container docker_container: name: nginx-static @@ -25,5 +38,6 @@ - "80:80" volumes: - "{{ site_dir.path }}:/usr/share/nginx/html" + - "{{ nginx_conf_dir.path }}:/etc/nginx/conf.d" restart_policy : "unless-stopped" init : true \ No newline at end of file diff --git a/ansible/playbooks/roles/nginx/templates/nginx.conf.j2 b/ansible/playbooks/roles/nginx/templates/nginx.conf.j2 new file mode 100644 index 0000000..42616a1 --- /dev/null +++ b/ansible/playbooks/roles/nginx/templates/nginx.conf.j2 @@ -0,0 +1,8 @@ +server { + listen 80; + listen [::]:80; + + root /var/www/html; + index index.html; + +} \ No newline at end of file