From 935ab02d44a2a1dd1f28ef71bf597c2213a5d393 Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Tue, 16 Sep 2025 13:43:50 +0200 Subject: [PATCH] [ini] --- README.md | 3 + galaxy.yml | 39 +++++++++++++ meta/runtime.yml | 52 +++++++++++++++++ plugins/README.md | 31 ++++++++++ roles/davina/defaults/main.json | 17 ++++++ roles/davina/tasks/main.json | 78 ++++++++++++++++++++++++++ roles/davina/templates/conf.json.j2 | 8 +++ roles/davina/templates/systemd_unit.j2 | 14 +++++ 8 files changed, 242 insertions(+) create mode 100644 README.md create mode 100644 galaxy.yml create mode 100644 meta/runtime.yml create mode 100644 plugins/README.md create mode 100644 roles/davina/defaults/main.json create mode 100644 roles/davina/tasks/main.json create mode 100644 roles/davina/templates/conf.json.j2 create mode 100644 roles/davina/templates/systemd_unit.j2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f29fd0 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Ansible Collection - fenris.zeitbild + +Documentation for the collection. diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 0000000..f89a9b8 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,39 @@ +namespace: fenris + +name: davina + +version: 1.0.0 + +readme: README.md + +authors: +- Royd Falk + +# description: your collection description + +license: +- GPL-2.0-or-later + +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: '' + +# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character +# requirements as 'namespace' and 'name' +tags: [] + +dependencies: {} + +repository: http://forgejo.ramsch.sx/davina/ + +# The URL to any online docs +# documentation: http://docs.example.com + +# The URL to the homepage of the collection/project +# homepage: http://example.com + +# The URL to the collection issue tracker +# issues: http://example.com/issue/tracker + +build_ignore: [] + diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 0000000..20f709e --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,52 @@ +--- +# Collections must specify a minimum required ansible version to upload +# to galaxy +# requires_ansible: '>=2.9.10' + +# Content that Ansible needs to load from another location or that has +# been deprecated/removed +# plugin_routing: +# action: +# redirected_plugin_name: +# redirect: ns.col.new_location +# deprecated_plugin_name: +# deprecation: +# removal_version: "4.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# removed_plugin_name: +# tombstone: +# removal_version: "2.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# become: +# cache: +# callback: +# cliconf: +# connection: +# doc_fragments: +# filter: +# httpapi: +# inventory: +# lookup: +# module_utils: +# modules: +# netconf: +# shell: +# strategy: +# terminal: +# test: +# vars: + +# Python import statements that Ansible needs to load from another location +# import_redirection: +# ansible_collections.ns.col.plugins.module_utils.old_location: +# redirect: ansible_collections.ns.col.plugins.module_utils.new_location + +# Groups of actions/modules that take a common set of options +# action_groups: +# group_name: +# - module1 +# - module2 diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 0000000..34cd30a --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,31 @@ +# Collections Plugins Directory + +This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that +is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that +would contain module utils and modules respectively. + +Here is an example directory of the majority of plugins currently supported by Ansible: + +``` +└── plugins + ├── action + ├── become + ├── cache + ├── callback + ├── cliconf + ├── connection + ├── filter + ├── httpapi + ├── inventory + ├── lookup + ├── module_utils + ├── modules + ├── netconf + ├── shell + ├── strategy + ├── terminal + ├── test + └── vars +``` + +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/2.14/plugins/plugins.html). diff --git a/roles/davina/defaults/main.json b/roles/davina/defaults/main.json new file mode 100644 index 0000000..e5f52ff --- /dev/null +++ b/roles/davina/defaults/main.json @@ -0,0 +1,17 @@ +{ + "var_davina_backend_directory": "/opt/davina", + "var_davina_backend_user": "davina", + "var_davina_backend_git_repository_url": "https://forgejo.ramsch.sx/davina/backend", + "var_davina_backend_git_reference": "main", + "var_davina_backend_auth": { + "kind": "none", + "data": null + }, + "var_davina_backend_source": { + "kind": "ics_feed", + "data": { + "url": "", + "combine": true + } + } +} diff --git a/roles/davina/tasks/main.json b/roles/davina/tasks/main.json new file mode 100644 index 0000000..4a00bb8 --- /dev/null +++ b/roles/davina/tasks/main.json @@ -0,0 +1,78 @@ +[ + { + "name": "packages", + "become": true, + "ansible.builtin.apt": { + "update_cache": true, + "pkg": [ + "git", + "make", + "rsync", + "nodejs" + ] + } + }, + { + "name": "user and directory", + "become": true, + "ansible.builtin.user": { + "name": "{{var_davina_backend_user}}", + "create_home": true, + "home": "{{var_davina_backend_directory}}" + } + }, + { + "name": "program | fetch", + "become": true, + "become_user": "{{var_davina_backend_user}}", + "ansible.builtin.git": { + "repo": "{{var_davina_backend_git_repository_url}}", + "version": "{{var_davina_backend_git_reference}}", + "dest": "/tmp/davina-backend-repo" + } + }, + { + "name": "program | build", + "become": true, + "become_user": "{{var_davina_backend_user}}", + "ansible.builtin.command": { + "chdir": "/tmp/davina-backend-repo", + "cmd": "tools/build" + } + }, + { + "name": "program | deploy", + "become": true, + "become_user": "{{var_davina_backend_user}}", + "ansible.builtin.command": { + "chdir": "/tmp/davina-backend-repo", + "cmd": "tools/deploy localhost --target-directory={{var_davina_backend_directory}}" + } + }, + { + "name": "conf", + "become": true, + "ansible.builtin.template": { + "src": "conf.json.j2", + "dest": "{{var_davina_backend_directory}}/conf.json", + "owner": "{{var_davina_backend_user}}" + } + }, + { + "name": "systemd unit", + "become": true, + "ansible.builtin.template": { + "src": "systemd_unit.j2", + "dest": "/etc/systemd/system/davina.service" + } + }, + { + "name": "run", + "become": true, + "ansible.builtin.systemd_service": { + "name": "davina", + "enabled": true, + "state": "restarted" + } + } +] diff --git a/roles/davina/templates/conf.json.j2 b/roles/davina/templates/conf.json.j2 new file mode 100644 index 0000000..c410b88 --- /dev/null +++ b/roles/davina/templates/conf.json.j2 @@ -0,0 +1,8 @@ +{ + "auth": {{ var_davina_backend_auth | json }}, + "source": {{ var_davina_backend_source | json }}, + "settings": { + "timezone": "UTC" + } +} + diff --git a/roles/davina/templates/systemd_unit.j2 b/roles/davina/templates/systemd_unit.j2 new file mode 100644 index 0000000..2f50887 --- /dev/null +++ b/roles/davina/templates/systemd_unit.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=davina +After=network.target + +[Service] +WorkingDirectory={{var_davina_backend_directory}} +ExecStart={{var_davina_backend_directory}}/davina serve +Type=simple +Restart=always +User={{var_davina_backend_user}} + +[Install] +WantedBy=default.target +RequiredBy=network.target