40 lines
923 B
YAML
40 lines
923 B
YAML
- name: Deploy a basic Nginx container
|
|
hosts: webservers
|
|
become: true
|
|
tasks:
|
|
- name: Ensure Docker is installed
|
|
apt:
|
|
name: docker.io
|
|
state: present
|
|
update_cache: yes
|
|
- name: Ensure pip is installed
|
|
apt:
|
|
name: pip
|
|
state: present
|
|
update_cache: yes
|
|
- name: Ensure Python Docker module is installed
|
|
apt:
|
|
name: python3-docker
|
|
state: present
|
|
|
|
- name: Ensure web root exists
|
|
file:
|
|
path: /opt/web
|
|
state: directory
|
|
|
|
- name: Copy index.html to web root
|
|
copy:
|
|
src: ../files/index.html
|
|
dest: /opt/web/index.html
|
|
|
|
- name: Run Nginx container
|
|
docker_container:
|
|
name: simple-nginx
|
|
image: nginx:alpine
|
|
state: started
|
|
restart_policy: always
|
|
ports:
|
|
- "8080:80"
|
|
volumes:
|
|
- "/opt/web:/usr/share/nginx/html:ro"
|