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