Add ola and foobazdmx role and add playbook for light.z9
This commit is contained in:
parent
35217737ce
commit
aefdd123a4
2
ansible.cfg
Normal file
2
ansible.cfg
Normal file
|
@ -0,0 +1,2 @@
|
|||
[defaults]
|
||||
inventory = ./inventories/thinkcccentre
|
3
collections/requirements.yml
Normal file
3
collections/requirements.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
collections:
|
||||
- community.general
|
8
inventories/thinkcccentre
Normal file
8
inventories/thinkcccentre
Normal file
|
@ -0,0 +1,8 @@
|
|||
all:
|
||||
children:
|
||||
debian_11:
|
||||
hosts:
|
||||
light:
|
||||
ansible_host: light.z9
|
||||
automation:
|
||||
ansible_host: automation.z9
|
10
playbooks/deploy_light.yml
Normal file
10
playbooks/deploy_light.yml
Normal 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
|
18
playbooks/roles/distribution_check/meta/argument_specs.yml
Normal file
18
playbooks/roles/distribution_check/meta/argument_specs.yml
Normal 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
|
20
playbooks/roles/distribution_check/tasks/main.yml
Normal file
20
playbooks/roles/distribution_check/tasks/main.yml
Normal 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
|
5
playbooks/roles/foobazdmx/handlers/main.yml
Normal file
5
playbooks/roles/foobazdmx/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
- name: Restart foobazdmx
|
||||
ansible.builtin.systemd:
|
||||
service: foobazdmx.service
|
||||
state: restarted
|
||||
daemon-reload: true
|
8
playbooks/roles/foobazdmx/meta/argument_specs.yml
Normal file
8
playbooks/roles/foobazdmx/meta/argument_specs.yml
Normal 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
|
8
playbooks/roles/foobazdmx/meta/main.yml
Normal file
8
playbooks/roles/foobazdmx/meta/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: distribution_check
|
||||
vars:
|
||||
distribution_check__supported_distributions:
|
||||
- name: Debian
|
||||
versions:
|
||||
- "11"
|
38
playbooks/roles/foobazdmx/tasks/main.yml
Normal file
38
playbooks/roles/foobazdmx/tasks/main.yml
Normal 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
|
10
playbooks/roles/foobazdmx/templates/foobazdmx.service.j2
Normal file
10
playbooks/roles/foobazdmx/templates/foobazdmx.service.j2
Normal 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
|
5
playbooks/roles/ola/handlers/main.yml
Normal file
5
playbooks/roles/ola/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
- name: Restart olad
|
||||
ansible.builtin.systemd:
|
||||
service: olad.service
|
||||
state: restarted
|
||||
daemon-reload: true
|
8
playbooks/roles/ola/meta/argument_specs.yml
Normal file
8
playbooks/roles/ola/meta/argument_specs.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
ola__enable_ftdi:
|
||||
description: Enable FTDI USB DMX support
|
||||
type: bool
|
||||
required: true
|
8
playbooks/roles/ola/meta/main.yml
Normal file
8
playbooks/roles/ola/meta/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: distribution_check
|
||||
vars:
|
||||
distribution_check__supported_distributions:
|
||||
- name: Debian
|
||||
versions:
|
||||
- "11"
|
15
playbooks/roles/ola/tasks/main.yml
Normal file
15
playbooks/roles/ola/tasks/main.yml
Normal 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
|
2
playbooks/roles/ola/templates/ola-ftdidmx.conf.j2
Normal file
2
playbooks/roles/ola/templates/ola-ftdidmx.conf.j2
Normal file
|
@ -0,0 +1,2 @@
|
|||
enabled = {{ ola__enable_ftdi | string | lower }}
|
||||
frequency = 30
|
Loading…
Reference in a new issue