885996101aa49d822cbfd2ab8daa085479883084
[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 and npm
192       block:
193         - name: 'Pull latest nodejs version'
194           command: 'curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt-get install -y nodejs'
195           become: yes
196         - name: 'Check nodejs version'
197           command: node --version
198         - name: 'Check npm version'
199           command: npm --version
200       when: ansible_distribution == 'Ubuntu'
201
202     - name: Install npm build tools
203       apt:
204         name: build-essential
205         update_cache: yes
206         state: fixed
207       become: true
208       when: ansible_distribution == 'Ubuntu'
209
210     - name: npm self-update
211       command: npm install npm@{{ npm_version }} -g
212       become: true
213       when: ansible_distribution == 'Ubuntu'
214
215     - name: npm install n module
216       command: npm install n -g
217       become: true
218       when: ansible_distribution == 'Ubuntu'
219
220     - name: Upgrade latest stable node version
221       command: n stable | PATH="$PATH"
222       become: true
223       when: ansible_distribution == 'Ubuntu'
224
225     - name: Add Google Chrome key
226       apt_key:
227         url: https://dl-ssl.google.com/linux/linux_signing_key.pub
228         state: present
229       become: true
230       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
231
232     - name: Add Google Chrome repo
233       copy: content="deb http://dl.google.com/linux/chrome/deb/ stable main" dest={{apt_file}} owner=root group=root mode=644
234       become: true
235       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
236
237     - name: Update apt cache
238       apt: update_cache=yes
239       become: true
240       when: ansible_distribution == 'Ubuntu'
241
242     - name: Install Google Chrome
243       apt:
244         name: google-chrome-stable
245         state: present
246       become: true
247       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
248
249     - name: Install Erlang dependency packages
250       apt:
251         name:
252           - libsctp1
253           - libwxbase3.0-0v5
254       become: true
255       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
256
257     - name: Install Erlang dependency package libwxgtk3 for 18.04
258       apt:
259         name:
260           - libwxgtk3.0-0v5
261       become: true
262       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'
263
264     - name: Install Erlang dependency package libwxgtk3 for 20.04
265       apt:
266         name:
267           - libwxgtk3.0-gtk3-0v5
268       become: true
269       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
270
271     - name: Download and install libssl Ubuntu 20.04
272       apt:
273         deb: http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.10_amd64.deb
274       become: true
275       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04'
276
277     - name: Install Erlang
278       apt:
279         deb: https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_24.1-1~ubuntu~trusty_amd64.deb
280       become: true
281       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
282
283     - name: 'Download latest rebar3 bin'
284       command: curl -o /usr/bin/rebar3 -L "https://s3.amazonaws.com/rebar3/rebar3"
285       become: true
286       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
287
288     - file:
289         path: /usr/bin/rebar3
290         mode: "+x"
291       become: true
292       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
293
294     - name: Download geckodriver
295       unarchive:
296         src: https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
297         dest: /usr/bin
298         mode: 0755
299         remote_src: yes
300       become: true
301       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
302
303     - name: Download Firefox version 55.0.3
304       unarchive:
305         src: https://download-installer.cdn.mozilla.net/pub/firefox/releases/55.0.3/linux-x86_64/en-US/firefox-55.0.3.tar.bz2
306         dest: /opt
307         mode: 0755
308         remote_src: yes
309       become: true
310       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
311
312     - name: Create symbolic link to firefox bin
313       file:
314         src: "/opt/firefox/firefox"
315         dest: "/usr/bin/firefox"
316         state: link
317       become: true
318       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
319
320     - name: Install jinja2
321       pip:
322         name: jinja2
323         state: present
324       become: true
325       when: ansible_architecture == 'x86_64'