43 lines
873 B
YAML
43 lines
873 B
YAML
---
|
|
- name: Pull docker image
|
|
docker_image:
|
|
name: "nginx"
|
|
source: pull
|
|
|
|
|
|
- name: Create site dir
|
|
file:
|
|
path: "/home/{{ ansible_user }}/web/static_nginx_site"
|
|
state: directory
|
|
register: site_dir
|
|
|
|
|
|
- name: Create index.html
|
|
template:
|
|
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
|
|
image: nginx
|
|
ports:
|
|
- "80:80"
|
|
volumes:
|
|
- "{{ site_dir.path }}:/usr/share/nginx/html"
|
|
- "{{ nginx_conf_dir.path }}:/etc/nginx/conf.d"
|
|
restart_policy : "unless-stopped"
|
|
init : true |