Skip to content

Commit

Permalink
Merge branch 'simplify-conditional-list-extension'
Browse files Browse the repository at this point in the history
* simplify-conditional-list-extension:
  chore: simplify conditional `kodi_extra_packages`
  fix(tests): ensure `kodi_codename` is defined
  • Loading branch information
tomeon committed Mar 18, 2024
2 parents ebd1dee + f20a016 commit b038f83
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 54 deletions.
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@

- name: Install Kodi and related apps
package:
name: "{{ (packages | default([])) + (kodi_extra_packages | default([])) }}"
name: "{{ packages_final }}"
state: present
when: "(((packages | default([])) + (kodi_extra_packages | default([]))) | length) > 0"
when: "(packages_final | length) > 0"
tags:
- install
- get_addons
Expand Down Expand Up @@ -316,7 +316,7 @@
become_user: "{{ kodi_user }}"
become: True
environment:
REPOSITORIES: "{{ kodi_repositories | map('quote') | list | join(' ') }}"
REPOSITORIES: "{{ kodi_repositories_final | map('quote') | list | join(' ') }}"
ENABLED_REPOSITORIES: "{{ kodi_enabled_repositories | map('quote') | list | join(' ') }}"
KODI_USER: "{{ kodi_user }}"
KODI_DATA_DIR: "{{ kodi_data_dir }}"
Expand Down
78 changes: 28 additions & 50 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,6 @@

- hosts: all
become: True
vars:
# Define this structure here, rather than in the `role` application stanza,
# so that we can extend it with the LibreELEC repository for LibreELEC
# hosts only.
kodi_repositories:
- 'official_cached=https://mirrors.kodi.tv/addons/{{ kodi_codename }}/addons.xml.gz'
- 'jellyfin_cached=https://repo.jellyfin.org/releases/client/kodi/addons.xml'
- 'sandmann79_cached=https://raw.githubusercontent.com/Sandmann79/xbmc/master/packages/addons.xml'
- 'sandmann79_py3_cached=https://raw.githubusercontent.com/Sandmann79/xbmc/master/packages-py3/addons.xml'
pre_tasks:
# The LibreELEC repository used to appear statically in the main
# `kodi_repositories` definition, but LibreELEC does aggressive
# rate-limiting on their repository, causing this playbook to fail from
# connection and/or HTTP errors.
#
# Reference for LibreELEC repository rate-limiting:
# https://forum.libreelec.tv/thread/26597-add-on-repository-problems-2024-03/?pageNo=1
#
# Note that LibreELEC appears to namespace addons under the path
# `<LibreELEC-major-version>.0.0`; for instance, the addon repository URL
# for LibreELEC release 11.0.6 is `https://addons.libreelec.tv/11.0.0/`.
- name: 'test | add LibreELEC repository for LibreELEC hosts'
set_fact:
kodi_repositories: '{{
kodi_repositories + [("libreelec_cached=https://addons.libreelec.tv/" ~ ansible_distribution_major_version ~ ".0.0/Generic/x86_64/addons.xml.gz")]
}}'
when: 'ansible_distribution == "LibreELEC"'

# NOTE that `kodi-inputstream-adaptive` does not ship with the base Kodi
# package, so we have to install `kodi-addon-inputstream-adaptive` on Arch
# Linux, and `kodi-inputstream-adaptive` elsewhere.
- name: 'test | define extra packages (Arch Linux)'
set_fact:
kodi_extra_packages:
- kodi-addon-inputstream-adaptive
when: 'ansible_distribution == "Archlinux"'

# LibreELEC and OSMC do not need additional packages (and, in LibreELEC's
# case, cannot install additional packages anyway).
- name: 'test | define extra packages (other)'
set_fact:
kodi_extra_packages:
- kodi-inputstream-adaptive
when: 'ansible_distribution not in ["Archlinux", "LibreELEC", "OSMC"]'

- name: 'test | add xvfb to extra packages for Debian and Ubuntu hosts'
set_fact:
kodi_extra_packages: '{{ (kodi_extra_packages | default([])) + ["xvfb"] }}'
when: 'ansible_distribution in ["Debian", "Ubuntu"]'
roles:
- role: "{{ playbook_dir | dirname }}"
vars:
Expand All @@ -95,6 +46,16 @@
- name: custom-group-for-testing
system: False
gid: 12345
# NOTE that `kodi-inputstream-adaptive` does not ship with the base
# Kodi package, so we have to install `kodi-addon-inputstream-adaptive`
# on Arch Linux, and `kodi-inputstream-adaptive` elsewhere.
#
# LibreELEC and OSMC do not need additional packages (and, in
# LibreELEC's case, cannot install additional packages anyway).
kodi_extra_packages:
- '{{ (ansible_distribution == "Archlinux") | ternary("kodi-addon-inputstream-adaptive", omit) }}'
- '{{ (ansible_distribution in ["Archlinux", "LibreELEC", "OSMC"]) | ternary(omit, "kodi-inputstream-adaptive") }}'
- '{{ (ansible_distribution in ["Debian", "Ubuntu"]) | ternary("xvfb", omit) }}'
kodi_language: 'en_US'
kodi_locale_country: 'United States'
kodi_locale_timezone_country: 'United States'
Expand All @@ -104,10 +65,27 @@
- repository.sandmann79-py3.plugins
- 'repository.jellyfin.kodi=https://repo.jellyfin.org/releases/client/kodi/repository.jellyfin.kodi.zip'
- plugin.video.youtube
- plugin.video.amazon-test
- plugin.video.jellyfin
- script.module.amazoncaptcha
- plugin.video.amazon-test
kodi_repositories:
- 'official_cached=https://mirrors.kodi.tv/addons/{{ kodi_codename }}/addons.xml.gz'
- 'jellyfin_cached=https://repo.jellyfin.org/releases/client/kodi/addons.xml'
- 'sandmann79_cached=https://raw.githubusercontent.com/Sandmann79/xbmc/master/packages/addons.xml'
- 'sandmann79_py3_cached=https://raw.githubusercontent.com/Sandmann79/xbmc/master/packages-py3/addons.xml'
# The LibreELEC repository used to appear statically in the main
# `kodi_repositories` definition, but LibreELEC does aggressive
# rate-limiting on their repository, causing this playbook to fail
# from connection and/or HTTP errors.
#
# Reference for LibreELEC repository rate-limiting:
# https://forum.libreelec.tv/thread/26597-add-on-repository-problems-2024-03/?pageNo=1
#
# Note that LibreELEC appears to namespace addons under the path
# `<LibreELEC-major-version>.0.0`; for instance, the addon repository
# URL for LibreELEC release 11.0.6 is
# `https://addons.libreelec.tv/11.0.0/`.
- '{{ (ansible_distribution == "LibreELEC") | ternary( ("libreelec_cached=https://addons.libreelec.tv/" ~ ansible_distribution_major_version ~ ".0.0/Generic/x86_64/addons.xml.gz"), omit) }}'
kodi_config:
- file: 'userdata/guisettings.xml'
key: 'settings/setting[@id="input.libinputkeyboardlayout"]'
Expand Down
8 changes: 7 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ kodi_config_cond_resolved: "{{ kodi_config_cond | selectattr('cond') | map(attri

kodi_config_final: "{{ kodi_config_cond_resolved + (kodi_config | default([])) }}"

kodi_repository_names: "{{ kodi_repositories | map('regex_search', '^[^=]*') | list }}"
# The special `omit` token signifies "leave me out". Mainly for the
# LibreELEC-related code in `tests/test.yml`.
kodi_repositories_final: "{{ kodi_repositories | reject('equalto', omit) | list }}"

kodi_repository_names: "{{ kodi_repositories_final | map('regex_search', '^[^=]*') | list }}"

kodi_addon_names: "{{ kodi_addons | map('regex_search', '^[^=]*') | list }}"

packages_final: "{{ ((packages | default([])) + (kodi_extra_packages | default([]))) | reject('equalto', omit) | list }}"

0 comments on commit b038f83

Please sign in to comment.