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