feat(ktra): add initial role

This commit is contained in:
Jan Christian Grünhage 2021-07-11 13:07:21 +02:00
parent 23d6bce78b
commit f93d7fdc03
7 changed files with 133 additions and 0 deletions

View file

@ -14,6 +14,7 @@ with no direct relation to any customers.
- [`ghost`](roles/ghost/README.md): a role for deploying the blogging platform [ghost](https://ghost.org/blog/).
- [`hedgedoc`](roles/hedgedoc/README.md): deploys [hedgedoc](https://hedgedoc.org/) (formerly known as `CodiMD`),
a polished and modern alternative to etherpad & co.
- [`ktra`](roles/ktra/README.md): a role for [ktra](https://book.ktra.dev/), a little self hostable cargo crate registry
- [`matomo`](roles/matomo/README.md): role for [matomo](https://matomo.org/) (formerly known as piwik), a web analytics tool
- [`murmur`](roles/murmur/README.md): deploys [murmur](https://www.mumble.info/downloads/), the mumble server software.
- [`snipe-it`](roles/snipe-it/README.md): used for deploying [SnipeIt](https://snipeitapp.com/), an open-source asset management.

24
roles/ktra/README.md Normal file
View file

@ -0,0 +1,24 @@
ktra
====
Deploys a containerized ktra instance.
Requirements
------------
- docker
Example Playbook
----------------
# TODO
License
-------
AGPL-3.0-only
Author Information
------------------
- Jan Christian Grünhage <jan.christian@gruenhage.xyz>

View file

@ -0,0 +1,18 @@
---
# defaults file for ktra
ktra_version: 0.5.1
ktra_user: "ktra"
ktra_base_path: "/opt/ktra"
ktra_container_name: "ktra"
ktra_container_image: "ghcr.io/moriturus/ktra"
ktra_container_image_tag: ~
ktra_container_image_ref: "{{ ktra_container_image }}:{{ ktra_container_image_tag | default(ktra_version, true) }}"
ktra_container_env: {}
ktra_container_labels: {}
ktra_container_ports:
- 8000:8000
ktra_container_volumes: []

View file

@ -0,0 +1,8 @@
---
# handlers file for ktra
- name: Restart ktra
docker_container:
name: "{{ ktra_container_name }}"
state: "started"
restart: yes
listen: "restart-ktra"

12
roles/ktra/meta/main.yml Normal file
View file

@ -0,0 +1,12 @@
galaxy_info:
author: Jan Christian Grünhage
description: deploys a containerized ktra instance
company: Famedly GmbH
license: AGPL-3.0-only
min_ansible_version: 2.10
galaxy_tags: []
dependencies: []

61
roles/ktra/tasks/main.yml Normal file
View file

@ -0,0 +1,61 @@
---
# tasks file for ktra
- name: Ensure user is created
user:
name: "{{ ktra_user }}"
state: present
system: yes
register: ktra_user_res
- name: Ensure directories are created
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: "{{ ktra_user_res.uid }}"
group: "{{ ktra_user_res.group }}"
loop:
- "{{ ktra_base_path }}"
- name: Clone index repository
git:
repo: "https://{{ ktra_git_user }}:{{ ktra_git_pass }}@gitlab.com/famedly/company/devops/crates-index.git"
dest: "{{ ktra_base_path }}/index"
reference: "{{ ktra_git_branch }}"
update: no
- name: Ensure configuration is templated
copy:
content: |
[index_config]
remote_url = "{{ ktra_git_url }}"
https_username = "{{ ktra_git_user }}"
https_password = "{{ ktra_git_pass }}"
git_email = "{{ ktra_git_mail }}"
git_name = "{{ ktra_git_name }}"
branch = "{{ ktra_git_branch }}"
dest: "{{ ktra_base_path }}/config.toml"
mode: 0600
owner: "{{ ktra_user_res.uid }}"
group: "{{ ktra_user_res.group }}"
notify: "restart-ktra"
- name: Ensure container is started
docker_container:
image: "{{ ktra_container_image_ref }}"
name: "{{ ktra_container_name }}"
state: started
pull: yes
restart_policy: unless-stopped
user: "{{ ktra_user_res.uid }}:{{ ktra_user_res.group }}"
volumes: "{{ ktra_container_volumes_merged }}"
ports: "{{ ktra_container_ports }}"
env: "{{ ktra_container_env }}"
labels: "{{ ktra_container_labels_merged }}"
working_dir: "{{ ktra_base_path }}"
entrypoint: "/ktra"
command:
- "-c"
- "/opt/ktra/config.toml"

9
roles/ktra/vars/main.yml Normal file
View file

@ -0,0 +1,9 @@
---
# vars file for ktra
ktra_container_labels_merged: "{{ ktra_container_labels_base | combine(ktra_container_labels) }}"
ktra_container_labels_base:
version: "{{ ktra_container_image_tag | default(ktra_version, true) }}"
ktra_container_volumes_merged: "{{ ktra_container_volumes_base + ktra_container_volumes }}"
ktra_container_volumes_base:
- "{{ ktra_base_path }}:{{ ktra_base_path }}"