diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..55d9c9b --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = ./inventories/thinkcccentre diff --git a/collections/requirements.yml b/collections/requirements.yml new file mode 100644 index 0000000..a24c121 --- /dev/null +++ b/collections/requirements.yml @@ -0,0 +1,3 @@ +--- +collections: + - community.general diff --git a/inventories/thinkcccentre b/inventories/thinkcccentre new file mode 100644 index 0000000..ad700f7 --- /dev/null +++ b/inventories/thinkcccentre @@ -0,0 +1,8 @@ +all: + children: + debian_11: + hosts: + light: + ansible_host: light.z9 + automation: + ansible_host: automation.z9 diff --git a/playbooks/deploy_light.yml b/playbooks/deploy_light.yml new file mode 100644 index 0000000..ea08ba8 --- /dev/null +++ b/playbooks/deploy_light.yml @@ -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 diff --git a/playbooks/roles/distribution_check/meta/argument_specs.yml b/playbooks/roles/distribution_check/meta/argument_specs.yml new file mode 100644 index 0000000..2332b34 --- /dev/null +++ b/playbooks/roles/distribution_check/meta/argument_specs.yml @@ -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 diff --git a/playbooks/roles/distribution_check/tasks/main.yml b/playbooks/roles/distribution_check/tasks/main.yml new file mode 100644 index 0000000..5ddda9a --- /dev/null +++ b/playbooks/roles/distribution_check/tasks/main.yml @@ -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 diff --git a/playbooks/roles/foobazdmx/handlers/main.yml b/playbooks/roles/foobazdmx/handlers/main.yml new file mode 100644 index 0000000..321abd6 --- /dev/null +++ b/playbooks/roles/foobazdmx/handlers/main.yml @@ -0,0 +1,5 @@ +- name: Restart foobazdmx + ansible.builtin.systemd: + service: foobazdmx.service + state: restarted + daemon-reload: true diff --git a/playbooks/roles/foobazdmx/meta/argument_specs.yml b/playbooks/roles/foobazdmx/meta/argument_specs.yml new file mode 100644 index 0000000..1e7d417 --- /dev/null +++ b/playbooks/roles/foobazdmx/meta/argument_specs.yml @@ -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 diff --git a/playbooks/roles/foobazdmx/meta/main.yml b/playbooks/roles/foobazdmx/meta/main.yml new file mode 100644 index 0000000..2c3bd99 --- /dev/null +++ b/playbooks/roles/foobazdmx/meta/main.yml @@ -0,0 +1,8 @@ +--- +dependencies: + - role: distribution_check + vars: + distribution_check__supported_distributions: + - name: Debian + versions: + - "11" diff --git a/playbooks/roles/foobazdmx/tasks/main.yml b/playbooks/roles/foobazdmx/tasks/main.yml new file mode 100644 index 0000000..fc66176 --- /dev/null +++ b/playbooks/roles/foobazdmx/tasks/main.yml @@ -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 diff --git a/playbooks/roles/foobazdmx/templates/foobazdmx.service.j2 b/playbooks/roles/foobazdmx/templates/foobazdmx.service.j2 new file mode 100644 index 0000000..17b61e0 --- /dev/null +++ b/playbooks/roles/foobazdmx/templates/foobazdmx.service.j2 @@ -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 diff --git a/playbooks/roles/ola/handlers/main.yml b/playbooks/roles/ola/handlers/main.yml new file mode 100644 index 0000000..0ab975d --- /dev/null +++ b/playbooks/roles/ola/handlers/main.yml @@ -0,0 +1,5 @@ +- name: Restart olad + ansible.builtin.systemd: + service: olad.service + state: restarted + daemon-reload: true diff --git a/playbooks/roles/ola/meta/argument_specs.yml b/playbooks/roles/ola/meta/argument_specs.yml new file mode 100644 index 0000000..2668214 --- /dev/null +++ b/playbooks/roles/ola/meta/argument_specs.yml @@ -0,0 +1,8 @@ +--- +argument_specs: + main: + options: + ola__enable_ftdi: + description: Enable FTDI USB DMX support + type: bool + required: true diff --git a/playbooks/roles/ola/meta/main.yml b/playbooks/roles/ola/meta/main.yml new file mode 100644 index 0000000..2c3bd99 --- /dev/null +++ b/playbooks/roles/ola/meta/main.yml @@ -0,0 +1,8 @@ +--- +dependencies: + - role: distribution_check + vars: + distribution_check__supported_distributions: + - name: Debian + versions: + - "11" diff --git a/playbooks/roles/ola/tasks/main.yml b/playbooks/roles/ola/tasks/main.yml new file mode 100644 index 0000000..3c4bf94 --- /dev/null +++ b/playbooks/roles/ola/tasks/main.yml @@ -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 diff --git a/playbooks/roles/ola/templates/ola-ftdidmx.conf.j2 b/playbooks/roles/ola/templates/ola-ftdidmx.conf.j2 new file mode 100644 index 0000000..d626e01 --- /dev/null +++ b/playbooks/roles/ola/templates/ola-ftdidmx.conf.j2 @@ -0,0 +1,2 @@ +enabled = {{ ola__enable_ftdi | string | lower }} +frequency = 30