Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix smaller stuff like linting, remove old stuff, update dependencies #96

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.vagrant
venv/
external_roles/
collections/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Freifunk Berlin Ansible Repo
# Freifunk Berlin Ansible Repository

This repository currently contains our WIP state for the infrastructure code.

Expand All @@ -21,7 +21,7 @@ This repository currently manages these services:

## Requirements

- Ansible 5.x
- Ansible 8.x
- The secret encryption password for ansible-vault under `./.vaultpass`
- For alternative methods look here: <https://docs.ansible.com/ansible/latest/user_guide/vault.html>
- Have the necessary requirements installed: `ansible-galaxy install -r requirements.yml`
Expand All @@ -35,7 +35,7 @@ Also, the roles are divided into 2 directories, one for external ones, and one f

This separation makes using the monorepo approach easier, since we can just exclude all directories in the `.gitignore`.

```
```text
├── .config # Directory with config files e.g. for github actions
├── .github # Directory for github actions
├── ansible.cfg # Custom settings for this Repository
Expand Down
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inventory = ./inventory/hosts
collections_paths = ./collections
roles_path = ./external_roles:./roles
vault_password_file = ./.vaultpass
ansible_managed = Managed by ff-berlin ansible: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
ansible_managed = Managed by ff-berlin ansible

forks = 10
allow_world_readable_tmpfiles=true
Expand Down
1 change: 0 additions & 1 deletion inventory/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ b.tunnel.berlin.freifunk.net # freifunk-gw01
c.tunnel.berlin.freifunk.net # vpn03d.berlin.freifunk.net
d.tunnel.berlin.freifunk.net # vpn03f.berlin.freifunk.net
f.tunnel.berlin.freifunk.net # vpn03h.berlin.freifunk.net
t-löffel.de

[other]
util.berlin.freifunk.net
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ansible >= 2.13
ansible >= 2.15
black >= 23.9
isort >= 5.12
12 changes: 6 additions & 6 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# usage: ansible-galaxy install -r requirements.yml
roles:
- src: ryandaniels.create_users
version: 1.0.8
version: 1.0.11
- src: geerlingguy.nginx
version: 3.1.0
version: 3.1.4
- src: systemli.letsencrypt
version: 2.1.0
version: 2.3.0
collections:
- name: ansible.posix
version: 1.5.1
version: 1.5.4
- name: community.mysql
version: 3.6.0
version: 3.8.0
- name: community.general
version: 6.5.0
version: 7.5.1
2 changes: 1 addition & 1 deletion roles/caddy/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Restart caddy
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: caddy
enabled: true
Expand Down
8 changes: 3 additions & 5 deletions roles/caddy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
state: present

- name: Install dependencies
apt:
ansible.builtin.apt:
name:
- caddy
state: present
update_cache: true
cache_valid_time: 3600

- name: Copy caddyfile
template:
ansible.builtin.template:
dest: /etc/caddy/Caddyfile
src: "{{ caddy_caddyfile }}"
mode: 0640
mode: "0640"
owner: caddy
group: caddy
notify: Restart caddy

...
6 changes: 0 additions & 6 deletions roles/common/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---
- name: Restart collectd
ansible.builtin.service:
name: collectd
enabled: true
state: restarted

- name: Restart fail2ban
ansible.builtin.service:
name: fail2ban
Expand Down
37 changes: 13 additions & 24 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
# tasks to be run on all machines
- name: Install basic tools
apt:
ansible.builtin.apt:
name:
- atop
- collectd
- curl
- fail2ban
- git
Expand All @@ -22,60 +21,50 @@
state: present
update_cache: true

# Collectd config
- name: Copy collectd config
template:
src: collectd-ffberlin.conf.j2
dest: /etc/collectd/collectd.conf.d/ffberlin.conf
mode: 0640
owner: root
group: root
notify: Restart collectd

- name: Configure fail2ban-jails
template:
ansible.builtin.template:
src: fail2ban-ffberlin.local.j2
dest: /etc/fail2ban/jail.local
mode: 0640
mode: "0640"
owner: root
group: root
notify: Restart fail2ban

- name: Copy custom motd
template:
ansible.builtin.template:
src: motd.j2
dest: /etc/motd
mode: 0640
mode: "0640"
owner: root
group: root

- name: Configure prometheus-node-exporter
template:
ansible.builtin.template:
src: prometheus-node-exporter.j2
dest: /etc/default/prometheus-node-exporter
mode: 0640
mode: "0640"
owner: root
group: root
notify: Restart prometheus-node-exporter

- name: Disallow password-based login for all users
lineinfile:
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
line: 'PasswordAuthentication no'
line: PasswordAuthentication no
insertafter: EOF
notify: Restart sshd

- name: Disallow login for root user
lineinfile:
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
line: 'PermitRootLogin no'
line: PermitRootLogin no
insertafter: EOF
notify: Restart sshd

- name: Set Journald Max Size to 1G
ansible.builtin.lineinfile:
path: /etc/systemd/journald.conf
insertafter: '^#SystemMaxUse'
regexp: '^SystemMaxUse'
insertafter: ^#SystemMaxUse
regexp: ^SystemMaxUse
line: SystemMaxUse=1G
notify: Restart journald
6 changes: 0 additions & 6 deletions roles/common/templates/collectd-ffberlin.conf.j2

This file was deleted.

10 changes: 5 additions & 5 deletions roles/ff_monitor/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
---
- name: Restart rrdcached
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: rrdcached
enabled: true
state: restarted

- name: Restart collectd
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: collectd
enabled: true
state: restarted

- name: Restart php-fpm
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: php7.4-fpm
enabled: true
state: restarted

- name: Restart prometheus
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: prometheus
enabled: true
state: restarted

- name: Restart grafana
systemd:
ansible.builtin.systemd:
daemon_reload: true
name: grafana-server
enabled: true
Expand Down
39 changes: 20 additions & 19 deletions roles/ff_monitor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

- name: Add grafana APT Repo
ansible.builtin.apt_repository:
repo: "deb https://apt.grafana.com stable main"
repo: deb https://apt.grafana.com stable main
state: present
update_cache: false

- name: Install dependencies
apt:
ansible.builtin.apt:
name:
- grafana
- prometheus
Expand All @@ -22,19 +22,19 @@
cache_valid_time: 3600

- name: Copy prometheus config
template:
ansible.builtin.template:
dest: /etc/prometheus/prometheus.yml
src: prometheus.yml.j2
mode: '0640'
mode: "0640"
owner: prometheus
group: prometheus
notify: Restart prometheus

- name: Copy prometheus defaults
template:
ansible.builtin.template:
dest: /etc/default/prometheus
src: prometheus.j2
mode: '0640'
mode: "0640"
owner: root
group: root
notify: Restart prometheus
Expand All @@ -53,19 +53,19 @@
- collectd-exporter

- name: Copy grafana config
template:
ansible.builtin.template:
dest: /etc/grafana/grafana.ini
src: grafana.ini.j2
mode: '0640'
mode: "0640"
owner: grafana
group: grafana
notify: Restart grafana

- name: Copy collectd config
template:
ansible.builtin.template:
dest: /etc/collectd/collectd.conf
src: collectd.conf.j2
mode: '0644'
mode: "0644"
owner: root
group: root
notify: Restart collectd
Expand All @@ -75,13 +75,13 @@
name: remove old rrd files
special_time: daily
user: root
job: "find /mnt/collectd/rrd/ -type f -mtime +14 -delete; find /mnt/collectd/rrd/ -type d -empty -delete"
job: find /mnt/collectd/rrd/ -type f -mtime +14 -delete; find /mnt/collectd/rrd/ -type d -empty -delete

- name: Create a directory if it does not exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: '0750'
mode: "0750"
owner: www-data
group: www-data
with_items:
Expand All @@ -94,17 +94,17 @@
ansible.builtin.copy:
src: files/firmwaremetrics/
dest: /srv/www/monitor.berlin.freifunk.net/metrics/firmware/
mode: '0750'
mode: "0750"
owner: www-data
group: www-data

- name: Copy helperscripts
ansible.builtin.copy:
src: "files/{{ item }}"
src: files/{{ item }}
dest: /opt/helperscripts/
owner: www-data
group: www-data
mode: '0750'
mode: "0750"
with_items:
- create_node_geojson.py
- create_node_list.py
Expand All @@ -114,26 +114,27 @@
name: create node json
special_time: daily
user: www-data
job: "/opt/helperscripts/create_node_list.py > /srv/www/monitor.berlin.freifunk.net/static/nodes.json"
job: /opt/helperscripts/create_node_list.py > /srv/www/monitor.berlin.freifunk.net/static/nodes.json

- name: Cronjob to create node geojson
ansible.builtin.cron:
name: create node geojson
special_time: daily
user: www-data
job: "/opt/helperscripts/create_node_geojson.py > /srv/www/monitor.berlin.freifunk.net/static/nodes_geojson.json"
job: /opt/helperscripts/create_node_geojson.py > /srv/www/monitor.berlin.freifunk.net/static/nodes_geojson.json

- name: Checkout CGP Repo
become: true
become_user: www-data
ansible.builtin.git:
repo: https://github.com/freifunk-berlin/CGP.git
dest: /srv/www/monitor.berlin.freifunk.net/cgp/
version: master

- name: Copy CGP config
template:
ansible.builtin.template:
dest: /srv/www/monitor.berlin.freifunk.net/cgp/conf/config.local.php
src: config.local.php.j2
mode: '0644'
mode: "0644"
owner: www-data
group: www-data
2 changes: 1 addition & 1 deletion roles/ff_monitor/templates/prometheus.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ ansible_managed }}
# Set the command-line arguments to pass to the server.

ARGS="--storage.tsdb.retention.size=70GB --enable-feature=memory-snapshot-on-shutdown --web.listen-address=127.0.0.1:9090"
ARGS="--storage.tsdb.retention.size=90GB --enable-feature=memory-snapshot-on-shutdown --web.listen-address=127.0.0.1:9090"
Loading