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