diff --git a/README.md b/README.md index b249a91..7fbac6d 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,106 @@ Server ========= -Essential server setup tasks, like sshd config, ddns cronjobs (+ mail output), etc. +Essential server setup tasks, like sshd config, ddns cronjobs (+ mail output), etc used by Jannik Beyerstedt. + Requirements ------------ -none TODO!! +none + Role Variables -------------- -If borgbackup is used, the following variables need to be set for each host. -Multiple hosts using the same backup account is currently not supported by the borgbackup script. -- borgbackup_host -- borgbackup_sub +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_host`: Hostname used by the borgbackup script +- `borgbackup_sub`: Sub-Account ID used by the borgbackup script + +Attention: You still need to setup the borgbackup repository manually. + +### Telegraf +Telegraf is configured with basic host telemetry by default. You can add more features, if you like: +- `telegraf_docker`: Set to `true`, if docker telemetry should be collected +- `telegraf_snmp_fra80`: Set to `true`, if SNMP telemetry of the fra80 network should be collected + Dependencies ------------ none + Example Playbook ---------------- -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: +The different tasks should be used on a case-by-case basis: +```yml +- name: Common Server Configuration + hosts: servers + strategy: free + 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: latest +``` - - hosts: servers - roles: - - { role: username.rolename, x: 42 } License ------- GPLv3 - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/defaults/main.yml b/defaults/main.yml index 1bbab8c..27d8ddc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,4 +2,4 @@ # defaults file for server telegraf_docker_file: "telegraf-docker.conf" -telegraf_snmp_file: "telegraf-SNMP.conf" +telegraf_snmp_fra80_file: "telegraf-SNMP_fra80.conf" diff --git a/tasks/main.yml b/tasks/main.yml index b705bef..d5eb939 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,10 @@ --- -# tasks file for server \ No newline at end of file +# Common Server Setup Tasks +# This default task will leave out mosts of the availabe tasks intentionnally. +# Activate them on a case-by-case basis. + +- name: Basic setup + import_tasks: setup.yml + +- name: Setup cronjob mails + import_tasks: cronmails.yml diff --git a/tasks/telegraf.yml b/tasks/telegraf.yml index 420014c..7f5e94a 100644 --- a/tasks/telegraf.yml +++ b/tasks/telegraf.yml @@ -1,7 +1,7 @@ --- # Server/Telegraf: Install and Setup Telegraf Monitoring # Variables: -# - telegraf_snmp: boolean, enable SNMP monitoring +# - telegraf_snmp_fra80: boolean, enable SNMP monitoring for the fra80 network # - telegraf_docker: boolean, enable docker monitoring - name: telegraf - Install apt-transport-https diff --git a/templates/telegraf-SNMP.conf b/templates/telegraf-SNMP_fra80.conf similarity index 100% rename from templates/telegraf-SNMP.conf rename to templates/telegraf-SNMP_fra80.conf diff --git a/templates/telegraf.conf b/templates/telegraf.conf index 0bc1987..dd3db39 100644 --- a/templates/telegraf.conf +++ b/templates/telegraf.conf @@ -65,8 +65,8 @@ {% endif %} -{% if telegraf_snmp|default(false)|bool %} -{% include telegraf_snmp_file %} +{% if telegraf_snmp_fra80|default(false)|bool %} +{% include telegraf_snmp_fra80_file %} {% endif %}