Merge "Update build node for failing vnfrqts job"
[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.17.1
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     - name: Install python-tox and deps
64       pip:
65         name:
66           - tox
67           - tox-pyenv
68           - virtualenv
69           - more-itertools~=5.0.0
70           - zipp==1.0.0
71         state: present
72       become: true
73
74     - apt_repository:
75         repo: ppa:deadsnakes/ppa
76         state: present
77       become: true
78       when: ansible_distribution == 'Ubuntu'
79
80     - name: Update and upgrade apt packages
81       apt:
82         upgrade: yes
83         update_cache: yes
84       become: true
85       when: ansible_distribution == 'Ubuntu'
86
87     - name: Install Python 3.6 and packages
88       apt:
89         name:
90           - python3.6
91           - python3.6-dev
92           - python3.6-tk
93           - libssl-dev
94           - libmysqlclient-dev
95           - gcc
96           - python3-venv
97       become: true
98       when: ansible_distribution == 'Ubuntu'
99
100     - name: Install Python 3.7
101       apt:
102         name:
103           - python3.7
104           - python3.7-dev
105           - python3.7-tk
106       become: true
107       when: ansible_distribution == 'Ubuntu'
108
109     - name: Install base packages
110       apt:
111         name:
112           - unzip
113           - xz-utils
114           - libxml-xpath-perl
115           - wget
116           - make
117           - sshuttle
118           - netcat
119           - nodejs-dev
120           - libssl1.0-dev
121           - libssl-dev
122           - libffi-dev
123           - xmlstarlet
124           - xvfb
125           - crudini
126           - maven
127           - python-ncclient
128           - xmlstarlet
129           - xvfb
130           - crudini
131           - maven
132           - python-ncclient
133           - nodejs
134           - npm
135         update_cache: yes
136         state: fixed
137       become: true
138       when: ansible_distribution == 'Ubuntu'
139
140     - name: Install npm addon packages
141       apt:
142         name:
143           - node-gyp
144         update_cache: yes
145         state: fixed
146       become: true
147       when: ansible_distribution == 'Ubuntu'
148
149     - name: Add Google Chrome key
150       apt_key:
151         url: https://dl-ssl.google.com/linux/linux_signing_key.pub
152         state: present
153       become: true
154       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
155
156     - name: Add Google Chrome repo
157       copy: content="deb http://dl.google.com/linux/chrome/deb/ stable main" dest={{apt_file}} owner=root group=root mode=644
158       become: true
159       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
160
161     - name: Update apt cache
162       apt: update_cache=yes
163       become: true
164       when: ansible_distribution == 'Ubuntu'
165
166     - name: Install Google Chrome
167       apt:
168         name: google-chrome-stable
169         state: present
170       become: true
171       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
172
173     - name: Install Erlang dependency packages
174       apt:
175         name:
176           - libwxgtk3.0-0v5
177           - libsctp1
178           - libwxbase3.0-0v5
179       become: true
180       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
181
182     - name: Install Erlang
183       apt:
184         deb: https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
185       become: true
186       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
187
188     - name: Clone rebar3
189       git:
190         repo: 'https://github.com/erlang/rebar3.git'
191         dest: /tmp/rebar3
192       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
193
194     - name: Bootstrap rebar3
195       command: ./bootstrap
196       args:
197         chdir: /tmp/rebar3
198       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
199
200     - name: Install rebar3 to bin
201       copy:
202         src: /tmp/rebar3/rebar3
203         dest: /usr/bin/rebar3
204         mode: 0755
205         remote_src: true
206       become: true
207       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
208
209     - name: Remove unused rebar3 source
210       file:
211         path: /tmp/rebar3
212         state: absent
213       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
214
215     - name: Download geckodriver
216       unarchive:
217         src: https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
218         dest: /usr/bin
219         mode: 0755
220         remote_src: yes
221       become: true
222       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
223
224     - name: Download Firefox version 55.0.3
225       unarchive:
226         src: https://download-installer.cdn.mozilla.net/pub/firefox/releases/55.0.3/linux-x86_64/en-US/firefox-55.0.3.tar.bz2
227         dest: /opt
228         mode: 0755
229         remote_src: yes
230       become: true
231       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
232
233     - name: Create symbolic link to firefox bin
234       file:
235         src: "/opt/firefox/firefox"
236         dest: "/usr/bin/firefox"
237         state: link
238       become: true
239       when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu'
240
241     - name: Install jinja2
242       pip:
243         name: jinja2
244         state: present
245       become: true
246       when: ansible_architecture == 'x86_64'