-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplaybook.yml
83 lines (73 loc) · 2.1 KB
/
playbook.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- name: Install latest version of docker and docker compose and setting proxy for that
hosts: webservers
become: true
vars:
ubuntu_release: <UBUNTU_RELEASE> # Edit this var
tasks:
- name: Uninstall old versions of docker
apt:
pkg:
- docker
- docker-engine
- docker.io
- containerd
- runc
state: absent
- name: Install required system packages
apt:
pkg:
- apt-transport-https
- gnupg
- lsb-release
- ca-certificates
- curl
- software-properties-common
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: yes
- name: Add docker GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu {{ ubuntu_release }} stable
state: present
- name: Update apt and install docker and docker compose
apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
update_cache: yes
- name: Create directory for proxy configuration
file:
path: /etc/systemd/system/docker.service.d/
state: directory
mode: 0775
- name: Copy proxy configuration for docker
copy:
src: ./proxy.conf
dest: /etc/systemd/system/docker.service.d/proxy.conf
mode: 0775
- name: Restart daemon_reload
command: systemctl daemon-reload
- name: restart docker.servive
service:
name: docker
state: restarted
- name: Run LEMP stack docker compose file
hosts: webservers
become: true
vars:
project_path: <PUT_ABSOLUTE_PATH_HERE> # Edit this var
tasks:
- name: Copy all LEMP stack files to server
synchronize:
src: "{{ project_path }}"
dest: /root
- name: Run compose file
command: docker compose -f /root/ComposeDockerNginxPHP/docker-compose.yml up -d