-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_playbook.yaml
203 lines (179 loc) · 4.89 KB
/
setup_playbook.yaml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
- name: Setup Environment
hosts: all
become: true
vars:
arch_mapping:
x86_64: amd64
aarch64: arm64
tasks:
- name: Update apt packages
apt:
update_cache: true
tags:
- installation
- name: Install required system packages
apt:
name: "{{ item }}"
state: latest
update_cache: true
loop:
- jq
- ca-certificates
- curl
- wget
- gnupg
- make
- dkms
- lsb-release
- apt-transport-https
- software-properties-common
- git
tags:
- installation
- name: Create directory for Docker's GPG key
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
tags:
- installation
- name: Add Docker's official GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /etc/apt/keyrings/docker.gpg
state: present
tags:
- installation
- name: Change GPG key permissions
file:
path: /etc/apt/keyrings/docker.gpg
state: file
mode: 'a+r'
tags:
- installation
- name: Set up the stable repository
apt_repository:
repo: deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
filename: docker
state: present
update_cache: true
tags:
- installation
- name: Install Docker and related packages
apt:
name: "{{ item }}"
state: present
update_cache: true
loop:
- docker-ce=5:27.1.1-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
- docker-ce-cli=5:27.1.1-1~ubuntu.{{ ansible_lsb.release }}~{{ ansible_lsb.codename }}
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
tags:
- installation
- name: Add Docker group
group:
name: docker
state: present
tags:
- installation
- name: Add user to docker group
user:
name: "{{ ansible_user_id }}"
groups: "docker"
append: true
tags:
- installation
- name: Enable and start Docker services
systemd:
name: "{{ item }}"
enabled: true
state: started
loop:
- docker.service
- containerd.service
tags:
- installation
- name: Create sysbox directory
file:
path: ./sysbox
state: directory
tags:
- installation
- name: Download sysbox package
get_url:
url:
https://downloads.nestybox.com/sysbox/releases/v{{ sysbox_ver }}/sysbox-ce_{{ sysbox_ver }}-0.linux_{{ arch_mapping[ansible_architecture] | default(ansible_architecture) }}.deb
dest: ./sysbox/sysbox-ce.deb
tags:
- installation
- name: Install sysbox package
apt: deb=./sysbox/sysbox-ce.deb
tags:
- installation
- name: Git clone shiftfs repository
git:
repo: https://github.com/toby63/shiftfs-dkms.git
dest: ./shiftfs-{{ shiftfs_ver }}
single_branch: yes
version: '{{ shiftfs_ver }}'
tags:
- installation
- name: Update kernel
shell: ./shiftfs-{{ shiftfs_ver }}/update1
tags:
- installation
- name: Build Makefile
make:
chdir: ./shiftfs-{{ shiftfs_ver }}
file: Makefile.dkms
tags:
- installation
- name: Copy dfaasagent directory
ansible.builtin.copy:
src: ./dfaasagent
dest: ~/dfaas/
tags:
- deploy
- name: Copy docker directory
ansible.builtin.copy:
src: ./docker
dest: ~/dfaas/
tags:
- deploy
- name: Copy docker compose file
ansible.builtin.copy:
src: ./docker-compose.yml
dest: ~/dfaas/
tags:
- deploy
- name: Copy ENV file
ansible.builtin.copy:
src: ./dfaasagent.env
dest: ~/dfaas/dfaasagent.env
tags:
- deploy
- name: Copy Operator directory
ansible.builtin.copy:
src: ./operator
dest: ~/dfaas/
tags:
- deploy
- name: Build Docker images
ansible.builtin.command:
chdir: ~/dfaas
cmd: "{{ item }}"
loop:
- "docker build -t dfaas-agent-builder:latest -f docker/dfaas-agent-builder.dockerfile dfaasagent"
- "docker build -t dfaas-node:latest -f docker/dfaas-node.dockerfile docker"
- "docker build -t dfaas-operator:latest -f operator/docker/dfaas-operator.dockerfile operator/docker"
tags:
- deploy
- name: Deploy Docker Compose stack
ansible.builtin.command:
chdir: ~/dfaas
cmd: docker compose up -d
tags:
- deploy