-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathmain.yml
More file actions
115 lines (104 loc) · 4.37 KB
/
Copy pathmain.yml
File metadata and controls
115 lines (104 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Copyright 2021 The Vitess Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Stop existing Vitess to build a new one
ansible.builtin.include_tasks: clean.yml
- name: Update Vitess
become: true
become_user: root
block:
# Building Vitess from source is the single most expensive step of a
# benchmark run (several minutes). When the same commit is benchmarked
# across several workloads, the cluster is torn down and recreated between
# each workload even though the exact same binaries are needed. We record
# the ref+Go version that is currently installed in a marker file and skip
# the fetch/build when it already matches (and the binaries are still
# present). The teardown no longer removes the vt* binaries, so they survive
# between workloads of the same commit.
- name: Read the installed Vitess build marker
ansible.builtin.slurp:
src: /usr/local/vitess-build.ref
register: vitess_build_marker
failed_when: false
changed_when: false
- name: Check whether the vtgate binary is present
ansible.builtin.stat:
path: /usr/local/bin/vtgate
register: vitess_vtgate_binary
- name: Determine whether the installed Vitess build can be reused
ansible.builtin.set_fact:
vitess_build_current: >-
{{
vitess_vtgate_binary.stat.exists
and vitess_build_marker.content is defined
and (vitess_build_marker.content | b64decode | trim)
== (vitess_git_version | default('') ~ '-' ~ golang_gover | default(''))
}}
- name: Report whether the Vitess build is reused
ansible.builtin.debug:
msg: >-
Vitess build {{ vitess_git_version | default('') }}-{{ golang_gover | default('') }}
reuse={{ vitess_build_current }}
- name: Build and install Vitess
when: not (vitess_build_current | bool)
block:
# Remove the marker first so an interrupted build cannot leave a stale
# marker that would make the next run wrongly skip the build.
- name: Invalidate the Vitess build marker before building
ansible.builtin.file:
path: /usr/local/vitess-build.ref
state: absent
- name: Fetch Updated Vitess
ansible.builtin.include_tasks: install_vitess.yml
- name: Tmp directory gopath
become: true
become_user: root
ansible.builtin.file:
state: directory
path: "{{ item }}"
mode: "0755"
with_items:
- /root/tmp
- name: Remove Vitess binaries
ansible.builtin.shell: |
rm -f /usr/local/bin/vt*
- name: Install Vitess Binaries
ansible.builtin.shell: |
export TMPDIR=/root/tmp
cd /go/src/vitess.io/vitess
NOVTADMINBUILD=1 make install PREFIX=/usr/local VTROOT=/go/src/vitess.io/vitess
changed_when: false
- name: Install Vitess Other Binaries
ansible.builtin.shell: |
cd /go/src/vitess.io/vitess
cp bin/vtctl /usr/local/bin/
changed_when: false
# Record the ref+Go version only after a fully successful install.
- name: Record the installed Vitess build marker
ansible.builtin.copy:
dest: /usr/local/vitess-build.ref
content: "{{ vitess_git_version | default('') }}-{{ golang_gover | default('') }}"
mode: "0644"
- name: Disbale AppArmor
block:
- name: Link apparmor
ansible.builtin.file:
state: link
src: /etc/apparmor.d/usr.sbin.mysqld
dest: /etc/apparmor.d/disable/
owner: root
group: root
ignore_errors: true
changed_when: false
- name: Disable apparmor for mysqld
ansible.builtin.command: apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
changed_when: false
ignore_errors: true