ec37f51acac15ef28600534e5f33c0d40e709876
[ci-management.git] / packer / provision / local-docker.yaml
1 ---
2 - import_playbook: ../common-packer/provision/docker.yaml
3
4 - hosts: all
5   become_user: root
6   become_method: sudo
7   vars:
8     apt_file: /etc/apt/sources.list.d/google-chrome.list
9     docker_compose_version: 1.29.2
10     glide_checksum: sha256:c403933503ea40308ecfadcff581ff0dc3190c57958808bb9eed016f13f6f32c
11     glide_version: v0.13.1
12     golang_version: 1.9.1
13     npm_version: "6.14.13"
14
15   tasks:
16     - name: "Checking for x86_64"
17       set_fact:
18         host_arch: "amd64"
19         golang_checksum: sha256:07d81c6b6b4c2dcf1b5ef7c27aaebd3691cdb40548500941f92b221147c5d9c7
20       when: "'x86_64' in ansible_architecture"
21
22     - name: "Checking for aarch64"
23       set_fact:
24         host_arch: "arm64"
25         golang_checksum: sha256:d31ecae36efea5197af271ccce86ccc2baf10d2e04f20d0fb75556ecf0614dad
26       when: "'aarch64' in ansible_architecture"
27
28     - name: 'Install Docker Compose {{docker_compose_version}}'
29       command: curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/{{docker_compose_version}}/docker-compose-Linux-x86_64"
30       become: true
31
32     - file:
33         path: /usr/local/bin/docker-compose
34         mode: "+x"
35       become: true
36
37     - name: 'Install GoLang {{golang_version}}'
38       block:
39         - name: 'Fetch golang {{golang_version}} to /tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz'
40           get_url:
41             url: 'https://storage.googleapis.com/golang/go{{golang_version}}.linux-{{host_arch}}.tar.gz'
42             dest: '/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz'
43             checksum: '{{golang_checksum}}'
44         - name: 'Install golang {{golang_version}} to /usr/local'
45           unarchive:
46             src: '/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz'
47             dest: /usr/local
48             remote_src: true
49           become: true
50         - name: Create symbolic link to go bin
51           file:
52             src: "/usr/local/go/bin/go"
53             dest: "/usr/bin/go"
54             state: link
55           become: true
56
57     - name: Install libxml2-utils
58       apt:
59         name: libxml2-utils
60         state: present
61       become: true
62       when: ansible_distribution == 'Ubuntu'
63
64     - apt_repository:
65         repo: ppa:deadsnakes/ppa
66         state: present
67       become: true
68       when: ansible_distribution == 'Ubuntu'
69
70     - name: Update and upgrade apt packages
71       apt:
72         upgrade: 'yes'
73         update_cache: yes
74       become: true
75       when: ansible_distribution == 'Ubuntu'
76
77     - name: Install Python 3.6 and packages
78       apt:
79         name:
80           - python3.6
81           - python3.6-dev
82           - python3.6-tk
83           - libssl-dev
84           - libmysqlclient-dev
85           - gcc
86           - python3-venv
87       become: true
88       when: ansible_distribution == 'Ubuntu'
89
90     - name: Install Python 3.7
91       apt:
92         name:
93           - python3.7
94           - python3.7-dev
95           - python3.7-tk
96       become: true
97       when: ansible_distribution == 'Ubuntu'
98
99     - name: Install Python 3.8
100       apt:
101         name:
102           - python3.8
103           - python3.8-dev
104           - python3.8-tk
105       become: true
106       when: ansible_distribution == 'Ubuntu'
107
108     - name: Install Python 3.9
109       apt:
110         name:
111           - python3.9
112           - python3.9-dev
113           - python3.9-tk
114           - python3.9-distutils
115       become: true
116       when: ansible_distribution == 'Ubuntu'
117
118     - name: Install nodejs-dev libssl1.0-dev dep
119       apt:
120         name:
121           - libssl1.0-dev
122         update_cache: yes
123         state: fixed
124       become: true
125       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
126
127     - name: Install nodejs-dev dep for npm
128       apt:
129         name:
130           - nodejs-dev
131         update_cache: yes
132         state: fixed
133       become: true
134       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
135
136     - name: Install supporting packages (Ubuntu 18.04)
137       apt:
138         name:
139           - unzip
140           - xz-utils
141           - libxml-xpath-perl
142           - wget
143           - make
144           - sshuttle
145           - netcat
146           - libssl-dev
147           - libffi-dev
148           - xmlstarlet
149           - xvfb
150           - crudini
151           - maven
152           - python-ncclient
153         update_cache: yes
154         state: fixed
155       become: true
156       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
157
158     - name: Install supporting packages (Ubuntu 20.04)
159       apt:
160         name:
161           - unzip
162           - xz-utils
163           - libxml-xpath-perl
164           - wget
165           - make
166           - sshuttle
167           - netcat
168           - libssl-dev
169           - libffi-dev
170           - xmlstarlet
171           - xvfb
172           - crudini
173           - maven
174           - python3-ncclient
175         update_cache: yes
176         state: fixed
177       become: true
178       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
179
180     - name: Install npm and addon packages
181       apt:
182         name:
183           - nodejs
184           - npm
185           - node-gyp
186         update_cache: yes
187         state: fixed
188       become: true
189       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
190
191     - name: Install nodejs
192       block:
193         - name: install nodejs prerequisites
194           apt:
195             name:
196               - apt-transport-https
197               - g++
198             update_cache: yes
199             state: present
200           become: true
201         - name: add nodejs apt key
202           apt_key:
203             url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
204             state: present
205         - name: add nodejs repository
206           apt_repository:
207             repo: deb https://deb.nodesource.com/node_19.x {{ ansible_distribution_release }} main
208             state: latest
209             update_cache: yes
210         - name: install nodejs
211           apt:
212             name:
213               - nodejs
214             state: present
215           become: true
216       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
217
218     - name: Check nodejs and npm versions
219       block:
220         - name: 'Check nodejs version'
221           command: node --version
222         - name: 'Check npm version'
223           command: npm --version
224       when: ansible_distribution == 'Ubuntu'
225
226     - name: Install npm build tools
227       apt:
228         name: build-essential
229         update_cache: yes
230         state: fixed
231       become: true
232       when: ansible_distribution == 'Ubuntu'
233
234     - name: npm self-update
235       command: npm install npm@{{ npm_version }} -g
236       become: true
237       when: ansible_distribution == 'Ubuntu'
238
239     - name: npm install n module
240       command: npm install n -g
241       become: true
242       when: ansible_distribution == 'Ubuntu'
243
244     - name: Upgrade latest stable node version
245       command: n stable | PATH="$PATH"
246       become: true
247       when: ansible_distribution == 'Ubuntu'
248
249     - name: Add Google Chrome key
250       apt_key:
251         url: https://dl-ssl.google.com/linux/linux_signing_key.pub
252         state: present
253       become: true
254       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
255
256     - name: Add Google Chrome repo
257       copy: content="deb http://dl.google.com/linux/chrome/deb/ stable main" dest={{apt_file}} owner=root group=root mode=644
258       become: true
259       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
260
261     - name: Update apt cache
262       apt: update_cache=yes
263       become: true
264       when: ansible_distribution == 'Ubuntu'
265
266     - name: Install Google Chrome
267       apt:
268         name: google-chrome-stable
269         state: present
270       become: true
271       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
272
273     - name: Install Erlang dependency packages
274       apt:
275         name:
276           - libsctp1
277           - libwxbase3.0-0v5
278       become: true
279       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
280
281     - name: Install Erlang dependency package libwxgtk3 for 18.04
282       apt:
283         name:
284           - libwxgtk3.0-0v5
285       become: true
286       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
287
288     - name: Install Erlang dependency package libwxgtk3 for 20.04
289       apt:
290         name:
291           - libwxgtk3.0-gtk3-0v5
292       become: true
293       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
294
295     - name: Download and install libssl Ubuntu 20.04
296       apt:
297         deb: http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.10_amd64.deb
298       become: true
299       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
300
301     - name: Install Erlang
302       apt:
303         deb: https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_24.1-1~ubuntu~trusty_amd64.deb
304       become: true
305       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
306
307     - name: 'Download latest rebar3 bin'
308       command: curl -o /usr/bin/rebar3 -L "https://s3.amazonaws.com/rebar3/rebar3"
309       become: true
310       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
311
312     - file:
313         path: /usr/bin/rebar3
314         mode: "+x"
315       become: true
316       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
317
318     - name: Download geckodriver
319       unarchive:
320         src: https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
321         dest: /usr/bin
322         mode: 0755
323         remote_src: yes
324       become: true
325       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
326
327     - name: Download Firefox version 55.0.3
328       unarchive:
329         src: https://download-installer.cdn.mozilla.net/pub/firefox/releases/55.0.3/linux-x86_64/en-US/firefox-55.0.3.tar.bz2
330         dest: /opt
331         mode: 0755
332         remote_src: yes
333       become: true
334       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
335
336     - name: Create symbolic link to firefox bin
337       file:
338         src: "/opt/firefox/firefox"
339         dest: "/usr/bin/firefox"
340         state: link
341       become: true
342       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
343
344     - name: Install jinja2
345       pip:
346         name: jinja2
347         state: present
348       become: true
349       when: ansible_architecture == 'x86_64'