-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yml
54 lines (47 loc) · 1.37 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: "Apache installation using docker"
hosts: prod
become: true
vars_files:
- files/secrets/credentials.vault
pre_tasks:
# - name: Add ansible SSH public key to remote host <authorized_key> file
# authorized_key:
# user: admin
# state: present
# key: "{{ lookup('file', '/home/admin/.ssh/id_rsa.pub') }}"
- name: Install EPEL repo, git, wget
yum:
name: "{{ item }}"
state: present
loop:
- epel-release
- wget
- git
when: ansible_distribution == "CentOS"
- name: download pip script
get_url:
url: https://bootstrap.pypa.io/pip/2.7/get-pip.py
dest: /tmp/get-pip.py
- name: install python-pip
command: python2.7 /tmp/get-pip.py
- name: Install docker python
pip: name=docker-py
tasks:
- name: Create website directory if it does not exist for docker volume binding
file:
path: /data/webapp/html
state: directory
mode: '0755'
- name: Generate website file from template to host directory
template:
src: templates/index.html.j2
dest: /data/webapp/html/index.html
- name: Create Apache container
docker_container:
name: webapp
image: httpd
ports:
- "80:80"
volumes:
- "/data/webapp/html:/usr/local/apache2/htdocs/"