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