Compare commits

..

8 Commits

Author SHA1 Message Date
uumas
472ad4286f Add role readmes 2023-03-24 18:41:26 +02:00
uumas
9103bafb8d v0.8.0 2023-03-24 18:31:44 +02:00
uumas
aa7216d6e2 Add Prometheus role 2023-03-21 01:33:57 +02:00
uumas
c569974ba7 Fix argument specs typo 2023-03-21 01:13:31 +02:00
uumas
d5f2bb84c6 Add Grafana role 2023-03-21 01:13:09 +02:00
uumas
265270eed3 Add DokuWiki role 2023-03-21 00:51:34 +02:00
uumas
93e76562f4 Generalize alpine argument_specs 2023-03-21 00:44:36 +02:00
uumas
0541367cb3 Update container argument_specs, add alpine role as a template 2023-03-21 00:32:01 +02:00
17 changed files with 322 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
namespace: uumas namespace: uumas
name: docker name: docker
description: Roles for installing services in docker containers description: Roles for installing services in docker containers
version: 0.7.2 version: 0.8.0
readme: README.md readme: README.md
repository: https://git.uumas.fi/uumas/ansible-docker repository: https://git.uumas.fi/uumas/ansible-docker
license_file: LICENSE license_file: LICENSE

1
roles/alpine/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up an alpine docker container. To be used as a template for other roles.

View File

@@ -0,0 +1,39 @@
---
argument_specs:
main:
short_description: Alpine container
description: "Sets up an alpine docker container. This role can be used as a template for other roles using the container role."
options:
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
database_passwords:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,15 @@
---
- name: Alpine container
import_role:
name: container
vars:
docker_service: alpine
docker_image: alpine
docker_image_http_port: 8080
docker_database: postgres
docker_mounts:
- name: data
path: /data
docker_env:
TZ: "{{ timezone }}"

View File

@@ -33,7 +33,7 @@ argument_specs:
- mongo - mongo
- none - none
default: none default: none
databse_passwords: database_passwords:
description: "database_passwords[docker_service] is a string with the password used for communication between the service and database. Required if docker_database is postgres or mariadb" description: "database_passwords[docker_service] is a string with the password used for communication between the service and database. Required if docker_database is postgres or mariadb"
type: dict type: dict
required: false required: false
@@ -99,9 +99,9 @@ argument_specs:
ports: ports:
description: "ports[docker_service]['http'] or ports[docker_service]['https'] defines the port on which the container will listen on for reverse proxy connections. Required if reverse_proxy_type is caddy." description: "ports[docker_service]['http'] or ports[docker_service]['https'] defines the port on which the container will listen on for reverse proxy connections. Required if reverse_proxy_type is caddy."
type: dict type: dict
required: false
docker_vhost_domains: docker_vhost_domains:
description: "docker_vhost_domains[docker_service] is a list which defines which domains should be proxied to the container. Required if reverse_proxy_type is not none" description: "docker_vhost_domains[docker_service] is a list which defines which domains should be proxied to the container. Required if reverse_proxy_type is not none"
type: dict
docker_published_ports: docker_published_ports:
description: "A list of published ports in docker format (<host listen address>:<host port>:<container port>)" description: "A list of published ports in docker format (<host listen address>:<host port>:<container port>)"
type: list type: list

1
roles/dokuwiki/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up a dokuwiki docker container.

View File

@@ -0,0 +1,4 @@
---
dokuwiki_wiki_name: DokuWiki
dokuwiki_admin_email: "{{ admin_email }}"

View File

@@ -0,0 +1,45 @@
---
argument_specs:
main:
short_description: DokuWiki container
description: "Sets up a DokuWiki docker container."
options:
dokuwiki_wiki_name:
description: Name of the DokuWiki site
type: str
reuired: false
default: DokuWiki
dokuwiki_admin_password:
description: Password of dokuwiki admin user
type: str
required: true
dokuwiki_admin_email:
description: Email address of dokuwiki admin user
type: str
required: false
default: "{{ admin_email }}"
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,18 @@
---
- name: Dokuwiki container
import_role:
name: container
vars:
docker_service: dokuwiki
docker_image: bitnami/dokuwiki
docker_image_http_port: 8080
docker_mounts:
- name: data
path: /bitnami/dokuwiki
docker_env:
DOKUWIKI_USERNAME: admin
DOKUWIKI_FULL_NAME: Admin
DOKUWIKI_PASSWORD: "{{ dokuwiki_admin_password }}"
DOKUWIKI_EMAIL: "{{ dokuwiki_admin_email }}"
DOKUWIKI_WIKI_NAME: "{{ dokuwiki_wiki_name }}"

1
roles/grafana/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up a grafana docker container.

View File

@@ -0,0 +1,38 @@
---
argument_specs:
main:
short_description: Alpine container
description: "Sets up an alpine docker container. This role can be used as a template for other roles using the container role."
options:
database_passwords:
description: "Passed to container role"
required: true
type: dict
docker_vhost_domains:
description: "Passed to container role"
required: true
type: dict
# All options after this will be passed directly to the container role
docker_host_user:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,21 @@
---
- name: Grafana container
import_role:
name: container
vars:
docker_service: grafana
docker_image: grafana/grafana
docker_image_http_port: 3000
docker_volumes:
- name: data
path: /var/lib/grafana
docker_database: postgres
docker_env:
GF_DATABASE_TYPE: postgres
GF_DATABASE_HOST: grafana_db:5432
GF_DATABASE_NAME: grafana
GF_DATABASE_USER: grafana
GF_DATABASE_PASSWORD: "{{ database_passwords.grafana }}"
GF_SERVER_DOMAIN: "{{ docker_vhost_domains.grafana[0] }}"
GF_SERVER_ROOT_URL: "https://{{ docker_vhost_domains.grafana[0] }}"

View File

@@ -0,0 +1 @@
Sets up a prometheus docker container.

View File

@@ -0,0 +1,6 @@
---
prometheus_scrape_interval: 5s
prometheus_evaluation_interval: 15s
prometheus_install_grafana: false
prometheus_hcloud_relabel_configs: []

View File

@@ -0,0 +1,73 @@
---
argument_specs:
main:
short_description: Prometheus docker container
options:
prometheus_scrape_interval:
description: Interval how often prometheus will scrape the monitoring targets
type: str
required: false
default: 5s
prometheus_evaluation_interval:
description: Interval how often prometheus will evaluate the scraped metrics against defined conditions
type: str
required: false
default: 15s
prometheus_hcloud_token:
description: Access token for hetzner cloud service discovery. It will be enabled if this variable is defined
type: str
required: false
prometheus_hcloud_relabel_configs:
description: Relabel configs for hcloud
type: list
required: false
default: []
elements: dict
options:
source_labels:
type: list
required: true
elements: str
target_label:
type: str
required: true
replacement:
type: str
required: false
prometheus_install_grafana:
description: If true, installs grafana in the same docker network as prometheus and configures it with prometheus as data source
type: bool
required: false
default: false
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
database_passwords:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,22 @@
---
- name: Prometheus container
import_role:
name: container
vars:
docker_service: prometheus
docker_image: prom/prometheus
reverse_proxy_type: none
docker_volumes:
- name: data
path: /prometheus
- template: prometheus.yml
path: /etc/prometheus/prometheus.yml
- name: Grafana container for prometheus
include_role:
name: grafana
vars:
docker_networks:
- name: prometheus
when: prometheus_install_grafana

View File

@@ -0,0 +1,34 @@
---
# my global config
global:
scrape_interval: {{ prometheus_scrape_interval }}
evaluation_interval: {{ prometheus_evaluation_interval }}
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
{% if prometheus_hcloud_token is defined %}
- job_name: hcloud
hetzner_sd_configs:
- role: hcloud
authorization:
credentials: {{ prometheus_hcloud_token }}
relabel_configs: {{ prometheus_hcloud_relabel_configs }}
{% endif %}