Skip to content

Commit

Permalink
ansible: add role to install Linux perf on Ubuntu
Browse files Browse the repository at this point in the history
Ansible role to install Linux perf on Ubuntu by cloning the Linux source
code and building tools/perf to avoid Kernel mismatch errors.

PR-URL: #1231
Ref: #1274
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information
Matheus Marchini authored and maclover7 committed Jun 9, 2018
1 parent 4a0bc9d commit a5d5962
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ansible/playbooks/jenkins/worker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@
- release-joyent-ubuntu1604_arm_cross-x64-1

roles:
- cross-compiler
- cross-compiler

#
# Install Linux perf on Ubuntu 16.04 servers
#

- hosts:
- test-*-ubuntu1604-x*
roles:
- linux-perf
46 changes: 46 additions & 0 deletions ansible/roles/linux-perf/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

#
# installs Linux perf @ /usr/local/bin/perf
#

- stat:
path: /usr/local/bin/perf
register: linux_perf
tags: linux_perf

- name: install perf on linux
tags: linux_perf
when: not (linux_perf.stat.exists | bool)
block:
- name: Clean path
file:
state: absent
path: "{{ tmp_folder }}"

- name: Download Linux source code
git:
repo: https://github.com/torvalds/linux.git
depth: 1
dest: "{{ tmp_folder }}/linux"

- name: Install packages
package:
name: "{{ package }}"
state: present
loop_control:
loop_var: package
with_items: "{{ packages }}"

- name: build Linux perf
shell: make -j{{ ansible_processor_cores | default(1) }}
args:
chdir: "{{ tmp_folder }}/linux/tools/perf"

- name: install Linux perf
shell: "cp {{ tmp_folder }}/linux/tools/perf/perf /usr/local/bin/perf"

- name: Clean path
file:
state: absent
path: "{{ tmp_folder }}"
6 changes: 6 additions & 0 deletions ansible/roles/linux-perf/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
packages:
- build-essential
- flex
- bison
tmp_folder: /data/tmp

0 comments on commit a5d5962

Please sign in to comment.