Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (53 sloc) 1.45 KB
# This playbook will install Docker and nginx on each host.
# In addition, it will create a standard index page that prints
# some details on the node using Jinja2
- name: Install Docker and nginx
hosts: all
become: yes
- name: install Docker
state: latest
update_cache: yes
force_apt_get: yes
# To use the docker module, we need the docker python module
# and to install this, we in turn need pip3
- name: Install pip3
name: python3-pip
state: latest
force_apt_get: yes
- name: Install docker python module
pip3 install docker
# Now we prepare our index.html file and copy
# it to the host
- name: create directory for content
state: directory
owner: vagrant
group: vagrant
path: /home/vagrant/web/
- name: Convert template into custom index.html
src: index.html.j2
dest: /home/vagrant/web/index.html
owner: vagrant
group: vagrant
mode: 0777
# We can finally deploy nginx now. We map port 80 in the container
# to port 80 on the host and map the directory /usr/share/nginx/html
# from which nginx servers content to ~/web on the host
- name: deploy nginx
image: nginx:latest
name: myNginx
network_mode: bridge
published_ports: 80:80
- /home/vagrant/web:/usr/share/nginx/html/
state: started
You can’t perform that action at this time.