Chore: Set NPM version to 9.6.4
[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: "9.6.4"
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 supporting packages (Ubuntu 18.04)
119       apt:
120         name:
121           - unzip
122           - xz-utils
123           - libxml-xpath-perl
124           - wget
125           - make
126           - sshuttle
127           - netcat
128           - libssl-dev
129           - libffi-dev
130           - xmlstarlet
131           - xvfb
132           - crudini
133           - maven
134           - python-ncclient
135         update_cache: yes
136         state: fixed
137       become: true
138       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
139
140     - name: Install supporting packages (Ubuntu 20.04)
141       apt:
142         name:
143           - unzip
144           - xz-utils
145           - libxml-xpath-perl
146           - wget
147           - make
148           - sshuttle
149           - netcat
150           - libssl-dev
151           - libffi-dev
152           - xmlstarlet
153           - xvfb
154           - crudini
155           - maven
156           - python3-ncclient
157         update_cache: yes
158         state: fixed
159       become: true
160       when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
161
162     - name: Install nodejs
163       block:
164         - name: install nodejs prerequisites
165           apt:
166             name:
167               - apt-transport-https
168               - g++
169             update_cache: yes
170             state: present
171           become: true
172         - name: add nodejs apt key
173           apt_key:
174             url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
175             state: present
176           become: true
177         - name: add nodejs repository
178           apt_repository:
179             repo: deb https://deb.nodesource.com/node_19.x {{ ansible_distribution_release }} main
180             state: present
181             update_cache: yes
182           become: true
183         - name: install nodejs
184           apt:
185             name:
186               - nodejs
187             state: present
188           become: true
189       when: ansible_distribution == 'Ubuntu'
190
191     - name: Check nodejs and npm versions
192       block:
193         - name: 'Check nodejs version'
194           command: node --version
195         - name: 'Check npm version'
196           command: npm --version
197       when: ansible_distribution == 'Ubuntu'
198
199     - name: Install npm build tools
200       apt:
201         name: build-essential
202         update_cache: yes
203         state: fixed
204       become: true
205       when: ansible_distribution == 'Ubuntu'
206
207     - name: npm self-update
208       command: npm install npm@{{ npm_version }} -g
209       become: true
210       when: ansible_distribution == 'Ubuntu'
211
212     - name: npm install n module
213       command: npm install n -g
214       become: true
215       when: ansible_distribution == 'Ubuntu'
216
217     - name: Upgrade latest stable node version
218       command: n stable | PATH="$PATH"
219       become: true
220       when: ansible_distribution == 'Ubuntu'
221
222     - name: Add Google Chrome key
223       apt_key:
224         url: https://dl-ssl.google.com/linux/linux_signing_key.pub
225         state: present
226       become: true
227       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
228
229     - name: Add Google Chrome repo
230       copy: content="deb http://dl.google.com/linux/chrome/deb/ stable main" dest={{apt_file}} owner=root group=root mode=644
231       become: true
232       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
233
234     - name: Update apt cache
235       apt: update_cache=yes
236       become: true
237       when: ansible_distribution == 'Ubuntu'
238
239     - name: Install Google Chrome
240       apt:
241         name: google-chrome-stable
242         state: present
243       become: true
244       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
245
246     - name: Install Erlang dependency packages
247       apt:
248         name:
249           - libsctp1
250           - libwxbase3.0-0v5
251       become: true
252       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
253
254     - name: Install Erlang dependency package libwxgtk3 for 18.04
255       apt:
256         name:
257           - libwxgtk3.0-0v5
258       become: true
259       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
260
261     - name: Install Erlang dependency package libwxgtk3 for 20.04
262       apt:
263         name:
264           - libwxgtk3.0-gtk3-0v5
265       become: true
266       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
267
268     - name: Download and install libssl Ubuntu 20.04
269       apt:
270         deb: http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.11_amd64.deb
271       become: true
272       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
273
274     - name: Install Erlang
275       apt:
276         deb: https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_24.1-1~ubuntu~trusty_amd64.deb
277       become: true
278       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
279
280     - name: 'Download latest rebar3 bin'
281       command: curl -o /usr/bin/rebar3 -L "https://s3.amazonaws.com/rebar3/rebar3"
282       become: true
283       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
284
285     - file:
286         path: /usr/bin/rebar3
287         mode: "+x"
288       become: true
289       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
290
291     - name: Download geckodriver
292       unarchive:
293         src: https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
294         dest: /usr/bin
295         mode: 0755
296         remote_src: yes
297       become: true
298       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
299
300     - name: Download Firefox version 55.0.3
301       unarchive:
302         src: https://download-installer.cdn.mozilla.net/pub/firefox/releases/55.0.3/linux-x86_64/en-US/firefox-55.0.3.tar.bz2
303         dest: /opt
304         mode: 0755
305         remote_src: yes
306       become: true
307       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
308
309     - name: Create symbolic link to firefox bin
310       file:
311         src: "/opt/firefox/firefox"
312         dest: "/usr/bin/firefox"
313         state: link
314       become: true
315       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
316
317     - name: Install jinja2
318       pip:
319         name: jinja2
320         state: present
321       become: true
322       when: ansible_architecture == 'x86_64'