Last active
February 28, 2019 11:03
-
-
Save goffinet/6f606829a1b9400adb0165d49455b55d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
# from the role mediapop/ansible-scaleway-linux-headers | |
gather_facts: true | |
tasks: | |
- name: "Set kernel facts" | |
set_fact: | |
scaleway_upstream_kernel: "{{ansible_kernel|regex_replace('-.*$', '')}}" | |
scaleway_local_kernel: "{{ansible_kernel|regex_replace('^[^-]+', '')}}" | |
- name: "Create a home for the kernel sources" | |
become: yes | |
file: | |
path: "/usr/src" | |
state: "directory" | |
- name: "Download the upstream kernel source" | |
become: yes | |
unarchive: | |
src: "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-{{scaleway_upstream_kernel}}.tar.xz" | |
creates: "/usr/src/linux-{{scaleway_upstream_kernel}}" | |
dest: "/usr/src/" | |
remote_src: yes | |
- name: "Symlink kernel sources" | |
become: yes | |
file: | |
state: "link" | |
src: "/usr/src/linux-{{scaleway_upstream_kernel}}" | |
dest: "{{item}}" | |
with_items: | |
- "/usr/src/linux" | |
- "/lib/modules/{{ansible_kernel}}/build" | |
- name: "Unpack the local config" | |
become: yes | |
shell: "zcat /proc/config.gz > /usr/src/linux/.config" | |
args: | |
creates: "/usr/src/linux/.config" | |
- name: "Set build config" | |
become: yes | |
lineinfile: | |
dest: "/usr/src/linux/.config" | |
line: "{{item}}" | |
with_items: | |
- "CONFIG_LOCALVERSION=\"{{scaleway_local_kernel}}\"" | |
- "CONFIG_CROSS_COMPILE=\"\"" | |
- name: "Download module symvers" | |
become: yes | |
get_url: | |
url: "http://mirror.scaleway.com/kernel/{{ansible_architecture}}/{{ansible_kernel}}/Module.symvers" | |
dest: "/usr/src/linux/Module.symvers" | |
- name: "Install packages necessary for kernel compilation" | |
become: yes | |
apt: | |
name: "{{item}}" | |
update_cache: no | |
loop: | |
- "build-essential" | |
- "libssl-dev" | |
- name: "Prepare sources" | |
become: yes | |
make: | |
chdir: "/usr/src/linux" | |
target: "{{item}}" | |
loop: | |
- "prepare" | |
- "modules_prepare" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment