Add ola and foobazdmx role and add playbook for light.z9

This commit is contained in:
yuri 2022-11-11 14:10:43 +01:00
parent 35217737ce
commit aefdd123a4
No known key found for this signature in database
GPG key ID: E646779AC54AEC64
16 changed files with 168 additions and 0 deletions

2
ansible.cfg Normal file
View file

@ -0,0 +1,2 @@
[defaults]
inventory = ./inventories/thinkcccentre

View file

@ -0,0 +1,3 @@
---
collections:
- community.general

View file

@ -0,0 +1,8 @@
all:
children:
debian_11:
hosts:
light:
ansible_host: light.z9
automation:
ansible_host: automation.z9

View file

@ -0,0 +1,10 @@
---
- name: Deploy ola and foobazdmx on light.z9
become: true
hosts: light
roles:
- ola
- foobazdmx
vars:
ola__enable_ftdi: true
foobazdmx__art_net_host: localhost

View file

@ -0,0 +1,18 @@
argument_specs:
main:
options:
distribution_check__supported_distributions:
description: A spec specifying the supported distribution.
type: list
elements: dict
required: true
options:
name:
description: The name of the supported distribution.
type: str
required: true
versions:
description: The supported versions of the supported distribution.
type: list
elements: str
required: true

View file

@ -0,0 +1,20 @@
- name: Set fact holding list of supported distribution names
ansible.builtin.set_fact:
distribution_check__supported_distribution_names: "{{ distribution_check__supported_distributions | community.general.json_query('[].name') }}"
- name: Fail on unsupported distribution (name)
ansible.builtin.fail:
msg: The hosts distribution (name) isn't supported.
when: ansible_facts.distribution not in distribution_check__supported_distribution_names
- name: Set fact holding list of supported distribution versions
ansible.builtin.set_fact:
distribution_check__supported_distribution_versions: "{{ distribution_check__supported_distributions
| community.general.json_query(distribution_check__supported_distribution_versions_query) }}"
vars:
distribution_check__supported_distribution_versions_query: "[?name=='{{ ansible_facts.distribution }}'].versions | [].to_string(@)"
- name: Fail on unsupported distribution version
ansible.builtin.fail:
msg: The hosts distribution version isn't supported.
when: ansible_facts.distribution_version not in distribution_check__supported_distribution_versions

View file

@ -0,0 +1,5 @@
- name: Restart foobazdmx
ansible.builtin.systemd:
service: foobazdmx.service
state: restarted
daemon-reload: true

View file

@ -0,0 +1,8 @@
---
argument_specs:
main:
options:
foobazdmx__art_net_host:
description: IP oder hostname of the Art-Net server
type: str
required: true

View file

@ -0,0 +1,8 @@
---
dependencies:
- role: distribution_check
vars:
distribution_check__supported_distributions:
- name: Debian
versions:
- "11"

View file

@ -0,0 +1,38 @@
- name: Ensure apt dependencies are installed
ansible.builtin.apt:
name:
- acl
- git
- python3
- python3-pip
- python3-setuptools
- name: Ensure python peotry is installed
ansible.builtin.pip:
name: poetry
- name: Ensure foobazdmx user exists
ansible.builtin.user:
name: foobazdmx
- name: Install foobazdmx
notify: Restart foobazdmx
block:
- name: Clone foobazdmx repository
ansible.builtin.git:
repo: https://thinkcccentre-ansible:glpat-VegCzyjuDjB19SggAqm1@gitlab.hamburg.ccc.de/yuri/foobazdmx.git
dest: /opt/foobazdmx
version: f0cbb639e8574c48b777ffe5a30db4298daf54c7
- name: Install python dependencies
become_user: foobazdmx
ansible.builtin.command:
cmd: poetry install
chdir: /opt/foobazdmx
changed_when: false
- name: Generate foobazdmx service file
ansible.builtin.template:
src: foobazdmx.service.j2
dest: /etc/systemd/system/foobazdmx.service
mode: "0755"
- name: Enable and start foobazdmx service
ansible.builtin.systemd:
service: foobazdmx.service
state: started
enabled: true

View file

@ -0,0 +1,10 @@
[Unit]
Description=Foobaz DMX
[Service]
ExecStart=poetry run python foobaz.py -a {{ foobazdmx__art_net_host }} -r big
WorkingDirectory=/opt/foobazdmx
User=foobazdmx
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,5 @@
- name: Restart olad
ansible.builtin.systemd:
service: olad.service
state: restarted
daemon-reload: true

View file

@ -0,0 +1,8 @@
---
argument_specs:
main:
options:
ola__enable_ftdi:
description: Enable FTDI USB DMX support
type: bool
required: true

View file

@ -0,0 +1,8 @@
---
dependencies:
- role: distribution_check
vars:
distribution_check__supported_distributions:
- name: Debian
versions:
- "11"

View file

@ -0,0 +1,15 @@
- name: Install ola
ansible.builtin.apt:
name: ola
- name: Generate ola-ftdidmx.conf
ansible.builtin.template:
src: ola-ftdidmx.conf.j2
dest: /etc/ola/ola-ftdidmx.conf
mode: "0664"
owner: olad
group: olad
- name: Enable and start ola service
ansible.builtin.systemd:
name: olad.service
state: started
enabled: true

View file

@ -0,0 +1,2 @@
enabled = {{ ola__enable_ftdi | string | lower }}
frequency = 30