Skip to content

Commit

Permalink
feat: adding udm kernel tools deployment (#8)
Browse files Browse the repository at this point in the history
with this change it is easy to rollout the udm custom kernel tools
  • Loading branch information
mabunixda authored Dec 23, 2021
1 parent ff3ac54 commit a844395
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ With this playbook:
certificate_key: <path-to-certificate-key.pem>
```
## UDM Kernel Tools
On default the [UDM Kernel tools](https://github.com/fabianishere/udm-kernel-tools) get not installed. When you enable the variable ```install_kernel_tools``` the tools and the latest kernel get installed. On default also the auto boot into the custom kernel is enabled. This can be switched off by ```udm_kernel_tools_autoboot```.

At the moment it is not supported to install an older kernel. If you have already installed an older kernel, you can switch to this kernel again by setting ```udm_kernel_tools_kernel_version``` manually to a version that is available. The role verifies that this actual version exists before applying the change and booting into this previous kernel.

Please read more about the kernel switch at [UDM Kernel tools](https://github.com/fabianishere/udm-kernel-tools) before giving it a try!

```yaml
---
- name: udmp setup
hosts: unifi-udmp-gateway
gather_facts: false
roles:
- role: mabunixda.ansible_udmp
install_kernel_tools: true
```

## You can configure following services:

Except the nodeexporter all services require configuration tasks after deploying the services. This configuration tasks must be done manually or by other roles/plays.
Expand Down
7 changes: 6 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ unifi_os_certificate_path: "{{ unifi_os_mount_path }}/unifi-core/config"
java_certificate_import: "java -jar /usr/lib/unifi/lib/ace.jar import_key_cert"

udm_onboot_version: 1.0.5
udm_onboot_download_uri: "https://github.com/boostchicken/udm-utilities/releases/download/{{ udm_onboot_version }}/udm-boot_{{ udm_onboot_version }}_all.deb"
udm_onboot_download_uri: "https://github.com/boostchicken/udm-utilities/releases/download/{{ udm_onboot_version }}/udm-boot_{{ udm_onboot_version }}_all.deb"

install_kernel_tools: no
udm_kernel_tools_autoboot: yes
udm_kernel_tool_version: 1.1.2
udm_kernel_tool_download_uri: "https://github.com/fabianishere/udm-kernel-tools/releases/download/v{{ udm_kernel_tool_version }}/udm-kernel-tools_{{ udm_kernel_tool_version }}_arm64.deb"
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ galaxy_info:
- udm
- unifi

dependencies: []
dependencies: []
71 changes: 71 additions & 0 deletions tasks/kernel-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---

- name: kernel-tools - check kernel tools version
register: kernel_tool_version
raw: "{{ unifi_os_cmd }} dpkg-query --showformat='${Version}' --show udm-kernel-tools"

- name: kernel-tools - installation
when: kernel_tool_version is not defined or ( kernel_tool_version.stdout != udm_kernel_tool_version)
block:
- name: kernel-tools - download package
raw: curl -L "{{ udm_kernel_tool_download_uri }}" -o "{{ unifi_mount_path }}/unifi-os/udm-kernel-tools_{{ udm_kernel_tool_version }}.deb"
- name: kernel-tools - install package
raw: "{{ unifi_os_cmd }} dpkg -i {{ unifi_os_mount_path }}/udm-kernel-tools_{{ udm_kernel_tool_version }}.deb"

- name: kernel-tools - fetch current kernel version
block:
- name: kernel-tools - get current kernel version
raw: "{{ unifi_os_cmd }} uname -r"
register: current_kernel_version_raw

- name: kernel-tools - update fact current kernel version
set_fact:
current_kernel_version: "{{ current_kernel_version_raw.stdout_lines[0] }}"

- name: kernel-tools - download latest kernel
when: udm_kernel_tools_kernel_version is not defined
block:
- name: kernel-tools - check latest udm-kernel
uri:
url: "{{ udm_kernel_release_url }}"
return_content: true
register: udm_kernel_latest_data

- name: "kernel-tools - download kernel {{ udm_kernel_latest_data.json.tag_name }}"
loop: "{{ udm_kernel_latest_data.json.assets }}"
when: "'udm-kernel' in item.name"
no_log: true
raw: curl -s -L "{{ item.browser_download_url }}" -o "{{ unifi_mount_path }}/unifi-os/{{ item.name }}"

- name: kernel-tools - set fact about downloaded kernel version
loop: "{{ udm_kernel_latest_data.json.assets }}"
when: "'udm-kernel' in item.name"
no_log: true
set_fact:
downloaded_file: "{{ item.name }}"
udm_kernel_tools_kernel_version: "{{ udm_kernel_latest_data.json.tag_name | regex_replace('^v(.*)', '\\1') }}"

- name: kernel-tools - install package
when: current_kernel_version != udm_kernel_tools_kernel_version
raw: "{{ unifi_os_cmd }} dpkg -i {{ unifi_os_mount_path }}/{{ downloaded_file }}"

- name: kernel-tools - verify kernel version
raw: "{{ unifi_os_cmd }} udm-bootctl list | awk '{print $1}' | tail -n +2"
register: installed_kernel_versions

- name: "kernel-tools - check if {{ udm_kernel_tools_kernel_version }} is installed..."
when: not udm_kernel_tools_kernel_version in installed_kernel_versions.stdout_lines
fail:
msg: "{{ udm_kernel_tools_kernel_version }} is not installed"

- name: kernel-tools - set default kernel version
when: current_kernel_version != udm_kernel_tools_kernel_version
raw: "{{ unifi_os_cmd }} udm-bootctl set-default {{ udm_kernel_tools_kernel_version }}"

- name: kernel-tools - ensure udm-autoboot is enabled
when: udm_kernel_tools_autoboot
raw: "{{ unifi_os_cmd }} systemctl enable udm-autoboot.service"

- name: "kernel-tools - boost custom kernel {{ udm_kernel_latest_data.json.tag_name }}"
when: current_kernel_version != udm_kernel_tools_kernel_version
raw: "{{ unifi_os_cmd }} udm-bootctl boot {{ udm_kernel_tools_kernel_version }}"
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@

- name: deploy onboot
include_tasks: onboot.yml

- name: deploy udm-kernel-tools
when: install_kernel_tools
include_tasks: kernel-tools.yml
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ unifi_os_container: "unifi-os"
unifi_os_cmd: podman exec -it "{{ unifi_os_container }}"

unifi_onboot_directory: "{{ unifi_mount_path }}/on_boot.d/"

udm_kernel_release_url: "https://api.github.com/repos/fabianishere/udm-kernel/releases/latest"

0 comments on commit a844395

Please sign in to comment.