defaults | ||
files | ||
handlers | ||
meta | ||
tasks | ||
templates | ||
README.md |
Server
Essential server setup tasks, like sshd config, ddns cronjobs (+ mail output), etc used by Jannik Beyerstedt.
Requirements
none
Role Variables
There are several variables, that should be set per host (e.g. in the inventory).
Some of the tasks listed below, will not run, if the corresponding variables are not set. Therefore you can use the same playbook for multiple servers and activate the needed features with host variables.
Borgbakup
If you want to configure borgbackup backups, these variables need to be set:
borgbackup_passphrase
: Passphrase of the borgbackup repoborgbackup_repo
: Repository path (e.g.ssh://$user@$hostname/$path
)borgbackup_hostname
: Hostname to prefix the snapshots
Optional configuration:
borgbackup_ssh_id
: Path to the used ssh id (default:/home/{{ ansible_user_id }}/.ssh/id_ed25519
)
Attention: You still need to setup the borgbackup repository manually.
Caddy
Mandatory variable:
caddy_email
: Email address to use for getting let's encrypt certificates
Cronmails
Mandatory variable:
cron_email
: Sender email address used by cron
Docker
Optional variable:
dockercompose_use_pip
: boolean to use pip instead of manual download (default: false)
DynDNS
This task and it's configuration files might be quite specific for the davd/docker-ddns docker container.
Mandatory variables:
ddns_server_domain
: Domain name of the DynDNS serverddns_passphrase
: Passphrase for updating dynDNS entriesddns_domain
: Domain where the host's entries are created as$hostname.$ddns_domain
Telegraf
Mandatory variables:
telegraf_server_url
: URL of the influxDB server, e.g.https://example.com:8086
telegraf_server_user
: Username of the influxDB usertelegraf_server_passwd
: Password of the influxDB user
Telegraf is configured with basic host telemetry by default. You can add more features, if you like:
telegraf_docker
: Set totrue
, if docker telemetry should be collected (uses file fromtelegraf_docker_file
)telegraf_snmp
: Set totrue
, if SNMP telemetry should be collected (uses file fromtelegraf_snmp_file
)telegraf_docker_file
: filename of the docker telegraf config part in{{role_path}}/templates
(defaulttelegraf-docker.conf
).telegraf_snmp_file
: filename of the SNMP telegraf config part in{{role_path}}/templates
(defaulttelegraf-SNMP.conf
).
Optional settings:
telegraf_interval
: Data sampling interval (default300s
)
Dependencies
none
Example Playbook
The different tasks should be used on a case-by-case basis:
- name: Common Server Configuration
hosts: servers
tasks:
- name: Servers - Generic setup tasks
import_role:
name: server
tasks_from: setup
- name: Servers - Setup cronjob mails
import_role:
name: server
tasks_from: cronmails
- name: Servers - Setup dyndns cronjob
import_role:
name: server
tasks_from: dyndns
- name: Servers - Setup monitoring
import_role:
name: server
tasks_from: telegraf
- name: Servers - Setup backups (if variables are set)
import_role:
name: server
tasks_from: borgbackup
# Docker
- name: Servers - Install docker
import_role:
name: server
tasks_from: docker
- name: Servers - Add telegraf to docker group
become: yes
user:
name: telegraf
groups: docker
append: yes
# Caddy Webserver
- name: Servers - Install and setup caddy
import_role:
name: server
tasks_from: caddyserver
- name: Servers - Start caddy service
become: yes
service:
name: caddy
enabled: yes
state: started
# UFW Firewall
- name: Servers - Install UFW
become: yes
apt:
name: ufw
state: present
License
GPLv3