Delete Ansible from installation process (#1604)

Resolves #1598
Resolves #1596

This reimplements the `load-tc358743-edid` service without Ansible,
which completes our process of eliminating Ansible from TinyPilot's
install process.

The last real piece was moving the installation of the
`load-tc358743-edid` from Ansible to Debian. The rest is just deleting
remaining Ansible files and stray references to Ansible.

Note that in deleting the Ansible environment setup, we delete `apt-get
update --allow-releaseinfo-change-suite` which we added in
https://github.com/tiny-pilot/tinypilot/issues/764. I don't think we
need this command anymore, but we can bring it back in the future if we
find that we need it.

## Manual tests

I ran the following manual tests:

* Verified keyboard and mouse still worked
* Verified that I could still adjust video settings
* Verified that audio still worked in H.264 (on Voyager systems)

For the following scenarios:

- [x] Install on a bare Raspbian system
- [x] Install on a bare Raspbian system with TC358743 enabled
- [x] Install a Pro Voyager image
- [x] Install a Pro Hobbyist image
- [x] Install a bundle on a Pro 2.6.0 Voyager image to simulate an
update

## Peer testing

To test this bundle run:

```bash
curl \
  --silent \
  --show-error \
  --location \
  https://raw.githubusercontent.com/tiny-pilot/tinypilot/master/scripts/install-bundle | \
  sudo bash -s -- \
    https://output.circle-artifacts.com/output/job/a5f0e73a-fc7b-4025-b6ce-c8f05c4be707/artifacts/0/bundler/dist/tinypilot-community-20230901T1513Z-1.9.0-109+51dc0af.tgz && \
  sudo reboot
```

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1604"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>

---------

Co-authored-by: David Brown <dave@sterki.co>
This commit is contained in:
Michael Lynch
2023-09-01 17:28:48 -04:00
committed by GitHub
parent a7cc8d036b
commit 9f547d2b85
26 changed files with 5 additions and 444 deletions

View File

@@ -181,33 +181,6 @@ jobs:
--fail-on warning,error \
"${file}"
done < <(ls *.deb)
build_ansible_role:
machine:
image: ubuntu-2004:202010-01
resource_class: large
working_directory: ~/project/ansible-role-ustreamer
steps:
- unless:
condition: << pipeline.parameters.ansible_role_changed >>
steps:
- run:
name: Skipping job because files weren't changed
command: circleci-agent step halt
- checkout:
path: ~/project
- run:
name: Create virtual environment
command: python3 -m venv venv
- run:
name: Test role with molecule
command: |
. venv/bin/activate && \
pip install --upgrade pip && \
pip install wheel==0.34.2 && \
pip install -r molecule/requirements.txt && \
ansible --version && \
molecule --version && \
molecule test
build_bundle:
docker:
- image: cimg/python:3.9.17
@@ -301,9 +274,6 @@ workflows:
- lint_debian_package:
requires:
- build_debian_package
- build_ansible_role:
requires:
- build_debian_package
- build_bundle:
requires:
- build_debian_package

View File

@@ -82,7 +82,6 @@ See the [CONTRIBUTING](CONTRIBUTING.md) file.
## Other installation options
- [Advanced installation options](https://github.com/tiny-pilot/tinypilot/wiki/Installation-Options#advanced-installation)
- [Remote installation via Ansible](https://github.com/tiny-pilot/tinypilot/wiki/Installation-Options#remote-installation)
## Updates

View File

@@ -1 +0,0 @@
venv

View File

@@ -1,33 +0,0 @@
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 Michael Lynch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,39 +0,0 @@
# Ansible Role: µStreamer
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](LICENSE)
Ansible role for [µStreamer](https://github.com/tiny-pilot/ustreamer).
Installs µStreamer via a Debian package and enables it as a systemd service.
## Role Variables
For a full list of options, see [defaults/main.yml](defaults/main.yml).
## Dependencies
None
## Example Playbook
#### `example.yml`
```yaml
- hosts: all
roles:
- role: ansible-role-ustreamer
```
### Running Example Playbook
```bash
ansible-playbook example.yml
```
## License
MIT
## Author Information
This role was created in 2020 by [TinyPilot](https://tinypilotkvm.com).

View File

@@ -1,22 +0,0 @@
---
- name: reload systemd config
systemd:
daemon_reload: yes
- name: load TC358743 EDID file
service:
name: load-tc358743-edid
state: started
# If the TC358743 is not yet attached, for example, when pre-provisioning an
# image, this will fail, but we can ignore it.
ignore_errors: yes
- name: configure TC358743 EDID loader to run at boot
systemd:
name: load-tc358743-edid
enabled: yes
- name: restart Janus
service:
name: janus
state: restarted

View File

@@ -1,20 +0,0 @@
---
galaxy_info:
role_name: ustreamer
author: Michael Lynch
description: A lightweight, optimized video streaming service
license: MIT
min_ansible_version: 2.8
platforms:
- name: Debian
versions:
- bullseye
galaxy_tags:
- raspberrypi
- usb
- oss
dependencies: []

View File

@@ -1,20 +0,0 @@
---
- name: Converge
hosts: all
gather_facts: no
tasks:
- name: Update apt cache and install system dependencies
apt:
name:
# To accurately detect the OS of the target machine, we need to
# install the lsb-release package before Ansible gathers facts. This
# ensures that the ansible_lsb fact is defined.
# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_conditionals.html#conditionals-based-on-ansible-facts
- lsb-release
update_cache: true
cache_valid_time: 600
- name: Gather facts
setup:
- name: Include ansible-role-ustreamer
include_role:
name: ansible-role-ustreamer

View File

@@ -1,33 +0,0 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: debian11
image: geerlingguy/docker-debian11-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
log: true
inventory:
hosts:
all:
vars:
ansible_user: root
verifier:
name: ansible
scenario:
name: default
test_sequence:
- lint
- destroy
- syntax
- create
- converge
- idempotence
- destroy

View File

@@ -1,59 +0,0 @@
# To update this file:
#
# 1. Delete the venv folder
# 2. Create a fresh venv folder with python3 -m venv venv
# 3. pip install the direct dependencies
# 4. Run pip freeze and save any indirect dependencies below
# 5. Remove dataclasses==0.8 and pkg_resources==0.0.0
# Direct dependencies
ansible==2.10.7
molecule==3.2.3
molecule-docker==0.2.4
# Indirect dependencies
ansible-base==2.10.17
arrow==1.2.2
bcrypt==3.2.2
binaryornot==0.4.4
Cerberus==1.3.4
certifi==2022.12.7
cffi==1.15.1
chardet==5.0.0
charset-normalizer==2.1.0
click==7.1.2
click-completion==0.5.2
click-help-colors==0.9.1
commonmark==0.9.1
cookiecutter==2.1.1
cryptography==39.0.1
distro==1.7.0
docker==5.0.3
enrich==1.2.7
idna==3.3
Jinja2==3.1.2
jinja2-time==0.2.0
MarkupSafe==2.1.1
packaging==21.3
paramiko==2.11.0
pathspec==0.9.0
pluggy==0.13.1
pycparser==2.21
Pygments==2.12.0
PyNaCl==1.5.0
pyparsing==3.0.9
python-dateutil==2.8.2
python-slugify==6.1.2
PyYAML==5.3.1
requests==2.28.1
rich==12.5.1
selinux==0.2.1
shellingham==1.5.0
six==1.16.0
subprocess-tee==0.3.5
text-unidecode==1.3
urllib3==1.26.11
websocket-client==1.3.3
yamllint==1.27.1

View File

@@ -1,31 +0,0 @@
---
- name: check for a boot config file
stat:
path: /boot/config.txt
register: boot_config_result
- name: save whether boot config file exists
set_fact:
boot_config_exists: "{{ boot_config_result.stat.exists }}"
- name: check if TC358743 settings (HDMI to CSI, such as Voyager series) are enabled
# We could theoretically use the "lineinfile" module to check for the overlay,
# but we're moving away from Ansible, and grep makes the logic easier to read.
command: grep --silent '^dtoverlay=tc358743$' /boot/config.txt
register: tc358743_result
check_mode: no
ignore_errors: yes
changed_when: no
when: boot_config_exists | bool
- name: save whether TC358743 settings are enabled
set_fact:
is_tc358743_enabled: "{{ boot_config_exists and tc358743_result.rc == 0 }}"
- name: print whether TC35843 settings are enabled
debug:
var: is_tc358743_enabled
- name: configure TC358743 HDMI capture chip
import_tasks: provision_tc358743.yml
when: is_tc358743_enabled | bool

View File

@@ -1,12 +0,0 @@
---
- name: install TC358743 initializer service
template:
src: load-tc358743-edid.systemd.j2
dest: /lib/systemd/system/load-tc358743-edid.service
owner: root
group: root
mode: "0644"
notify:
- reload systemd config
- load TC358743 EDID file
- configure TC358743 EDID loader to run at boot

View File

@@ -187,43 +187,6 @@ _LICENSE_METADATA = [
'./venv/lib/python3.*/site-packages/zipp-*.dist-info/LICENSE*',
),
# Ansible dependencies that are not covered above. They are not available
# permanently on the device because we only create ephemeral Ansible install
# environments.
LicenseMetadata(
name='Ansible',
homepage_url='https://www.ansible.com',
license_url=
'https://raw.githubusercontent.com/ansible/ansible/v2.10.7/COPYING'),
LicenseMetadata(
name='cffi',
homepage_url='http://cffi.readthedocs.org/',
license_url='https://foss.heptapod.net/pypy/cffi/-/raw/v1.15.1/LICENSE'
),
LicenseMetadata(
name='cryptography',
homepage_url='https://cryptography.io',
license_url=
'https://raw.githubusercontent.com/pyca/cryptography/37.0.4/LICENSE.BSD'
),
LicenseMetadata(
name='packaging',
homepage_url='https://github.com/pypa/packaging',
license_url=
'https://raw.githubusercontent.com/pypa/packaging/21.3/LICENSE.BSD'),
LicenseMetadata(
name='pycparser',
homepage_url='https://github.com/eliben/pycparser',
license_url=
'https://raw.githubusercontent.com/eliben/pycparser/release_v2.21/LICENSE'
),
LicenseMetadata(
name='pyparsing',
homepage_url='https://github.com/pyparsing/pyparsing/',
license_url=
'https://raw.githubusercontent.com/pyparsing/pyparsing/pyparsing_3.0.9/LICENSE'
),
# Indirect dependencies through Janus.
LicenseMetadata(
name='libnice',

1
bundler/.gitignore vendored
View File

@@ -1,6 +1,5 @@
# Dynamic dependencies from dist/ folder.
/bundle/tinypilot
/bundle/roles
/bundle/*.deb
/bundle/yq

View File

@@ -12,8 +12,6 @@ The [`create-bundle`](create-bundle) script generates the bundle from the [`bund
- **The TinyPilot web service**
- The root [`Dockerfile`](../Dockerfile) packs the TinyPilot web service as a Debian package from the source files.
- **Ansible role**
- [`ansible-role-ustreamer`](../ansible-role-ustreamer) is responsible for configuring uStreamer on the device.
- **Metadata**
- E.g., version/build information

View File

@@ -1,4 +0,0 @@
[defaults]
remote_user = root
roles_path = ./roles
interpreter_python = /usr/bin/python3

View File

@@ -58,40 +58,3 @@ apt-get install -y \
# Install yq.
mv yq /usr/bin/yq
chmod 0755 /usr/bin/yq
# Bootstrap environment for installation.
apt-get update --allow-releaseinfo-change-suite
apt-get install -y \
git \
libffi-dev \
libssl-dev \
python3-dev \
python3-venv \
lsb-release
python3 -m venv venv
# shellcheck disable=SC1091 # Dont follow sourced script.
. venv/bin/activate
# Ensure we're using a version of pip that can use binary wheels where available
# instead of building the packages locally.
pip install "pip>=21.3.1"
pip install -r requirements.txt
# If there's an existing TinyPilot settings file, pass it to Ansible to override
# default vars.
readonly TINYPILOT_SETTINGS_FILE='/home/tinypilot/settings.yml'
EXTRA_PLAYBOOK_FLAGS=()
# Check that TinyPilot settings file exists and is non-empty.
if [[ -s "${TINYPILOT_SETTINGS_FILE}" ]]; then
EXTRA_PLAYBOOK_FLAGS+=('--extra-vars' "@${TINYPILOT_SETTINGS_FILE}")
echo "Final install settings:"
cat "${TINYPILOT_SETTINGS_FILE}"
fi
readonly EXTRA_PLAYBOOK_FLAGS
# Run Ansible.
ansible-playbook \
--inventory localhost, \
install.yml \
"${EXTRA_PLAYBOOK_FLAGS[@]}"

View File

@@ -1,6 +0,0 @@
- hosts: localhost
connection: local
become: true
become_method: sudo
roles:
- role: ansible-role-ustreamer

View File

@@ -1,16 +0,0 @@
# Minimal set of dependencies to bootstrap an Ansible virtualenv.
# When modifying dependencies, update the credit in /app/license_notice.py
# Direct dependencies.
ansible==2.10.7
# Indirect dependencies.
ansible-base==2.10.17
cffi==1.15.1
cryptography==37.0.4
Jinja2==3.1.2
MarkupSafe==2.1.1
packaging==21.3
pycparser==2.21
pyparsing==3.0.9
PyYAML==6.0.1

View File

@@ -24,9 +24,6 @@ cd ./bundler
readonly BUNDLE_DIR='bundle'
readonly OUTPUT_DIR='dist'
readonly ANSIBLE_ROLES_DIR="${BUNDLE_DIR}/roles"
readonly ANSIBLE_ROLE_USTREAMER_DIR="${ANSIBLE_ROLES_DIR}/ansible-role-ustreamer"
# Exclude the AMD64 package from the production bundle.
rm -f "${BUNDLE_DIR}/tinypilot"*amd64.deb
@@ -65,15 +62,6 @@ readonly TINYPILOT_VERSION
readonly TINYPILOT_VARIANT='community'
readonly BUNDLE_FILENAME="tinypilot-${TINYPILOT_VARIANT}-${TIMESTAMP}-${TINYPILOT_VERSION}.tgz"
# Clear Ansible roles from any previous bundle builds.
rm -rf "${ANSIBLE_ROLES_DIR}"
mkdir "${ANSIBLE_ROLES_DIR}"
# Copy local Ansible roles.
cp -r \
--no-target-directory \
../ansible-role-ustreamer "${ANSIBLE_ROLE_USTREAMER_DIR}"
# Download Janus Bullseye Backports Debian package.
wget \
--directory-prefix="${BUNDLE_DIR}" \

View File

@@ -43,9 +43,3 @@ fi
# List Debian package contents.
dpkg --contents tinypilot*armhf.deb
# Check that the Ansible role exists.
if [[ ! -d 'roles/ansible-role-ustreamer' ]]; then
>&2 echo 'Bundle is missing ansible-role-ustreamer'
exit 1
fi

View File

@@ -13,6 +13,7 @@ export DEB_BUILD_OPTIONS=noddebs
dh $@ --with python-virtualenv
override_dh_installsystemd:
dh_installsystemd --name=load-tc358743-edid --no-start
dh_installsystemd --name=tinypilot
dh_installsystemd --name=tinypilot-updater --no-start --no-enable
dh_installsystemd --name=usb-gadget --no-start

View File

@@ -215,4 +215,7 @@ cp \
/usr/share/tinypilot/janus.transport.websockets.jcfg \
/etc/janus/janus.transport.websockets.jcfg
# Restart Janus to pick up the new config files.
deb-systemd-invoke restart janus
#DEBHELPER#

View File

@@ -6,7 +6,7 @@ upstream ustreamer {
}
upstream janus-ws {
# The host and port must match the variables in
# ansible-role-ustreamer/templates/janus.transport.websockets.jcfg.j2
# debian-pkg/usr/share/tinypilot/janus.transport.websockets.jcfg
server 127.0.0.1:48002 fail_timeout=1s max_fails=600;
}