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