ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit ae6bd9543d98ca70fbe9baf76923361d4d404bee
parent ffdcab3e634d28ca63e31ee5dfeafa4aaaab4db1
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 3 Feb 2021 18:21:51 +0100

update playbook and config
3 files changed, 85 insertions(+), 34 deletions(-)
M
configuration/lollo.yml
|
96
+++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
M
configuration/wanderduene.yml
|
10
++++++++++
M
playbook.yml
|
13
+++++++++++--
diff --git a/configuration/lollo.yml b/configuration/lollo.yml
@@ -121,6 +121,32 @@ networkd:
         - Network:
           - DHCP: yes
 
+timers:
+   powermeter-archiver:
+      timer_command: php /usr/local/bin/powermeter-archiver.php
+      timer_user: leah
+      timer_OnCalendar: "minutely"
+      timer_AccuracySec: 5s
+
+files:
+  /etc/udev/rules.d/99-modbus-serial.rules:
+    state:   "file"
+    content: 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1d6b", ATTRS{serial}=="0000:00:15.0", SYMLINK+="modbus0"'
+    mode:    "0755"
+    owner:   "root"
+    group:   "root"
+  /usr/local/bin/powermeter-archiver.php:
+    state:   "file"
+    src:     "scripts/powermeter-archiver.php"
+    mode:    "0755"
+    owner:   "root"
+    group:   "root"
+  /var/lib/powermeter-archive:
+    state:   "directory"
+    mode:    "0755"
+    owner:   "leah"
+    group:   "nginx"
+
 services:
   prometheus_node_exporter:
     enable: true

@@ -146,12 +172,11 @@ services:
           - legacy.home.ctu.cx
         renew_tasks:
           - chown -R acme-redirect:acme-redirect /var/lib/acme-redirect/live/home.ctu.cx
-      home.flauschekatze.space:
+      dnsmasq.home.ctu.cx:
         dns_names: 
-          - home.flauschekatze.space
-          - legacy.home.flauschekatze.space
+          - dnsmasq.home.ctu.cx
         renew_tasks:
-          - chown -R acme-redirect:acme-redirect /var/lib/acme-redirect/live/home.flauschekatze.space
+          - chown -R acme-redirect:acme-redirect /var/lib/acme-redirect/live/dnsmasq.home.ctu.cx
 
   nginx:
     enable: true

@@ -166,33 +191,16 @@ services:
         locations:
           - path: /node-exporter
             proxy: http://127.0.0.1:9100/metrics
-      home.ctu.cx legacy.home.ctu.cx:
-        root: /var/lib/websites/home.ctu.cx
+      dnsmasq.home.ctu.cx:
+        root: /var/lib/websites/dnsmasq.home.ctu.cx
         extraConfig: "
           index index.html index.php;
           try_files $uri $uri/ /index.php?$query_string;
         "
         ssl:
           enable: true
-          cert: "/var/lib/acme-redirect/live/home.ctu.cx/fullchain"
-          privkey: "/var/lib/acme-redirect/live/home.ctu.cx/privkey"
-        locations:
-          - path: ~ \.php$
-            extraConfig: "
-              fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
-              fastcgi_index index.php;
-              include fastcgi_params;
-            "
-      home.flauschekatze.space legacy.home.flauschekatze.space:
-        root: /var/lib/websites/home.ctu.cx
-        extraConfig: "
-          index index.html index.php;
-          try_files $uri $uri/ /index.php?$query_string;
-        "
-        ssl:
-          enable: true
-          cert: "/var/lib/acme-redirect/live/home.flauschekatze.space/fullchain"
-          privkey: "/var/lib/acme-redirect/live/home.flauschekatze.space/privkey"
+          cert: "/var/lib/acme-redirect/live/dnsmasq.home.ctu.cx/fullchain"
+          privkey: "/var/lib/acme-redirect/live/dnsmasq.home.ctu.cx/privkey"
         locations:
           - path: ~ \.php$
             extraConfig: "

@@ -224,19 +232,20 @@ services:
     auth_server: home.ctu.cx, wg-pbb
     auth_zones:
       - home.ctu.cx,                        10.0.0.1/24,   195.39.246.32/28,   2a0f:4ac0:acab::1/64
-      - home.flauschekatze.space,           10.0.0.1/24,   195.39.246.32/28,   2a0f:4ac0:acab::1/64
+#      - home.flauschekatze.space,           10.0.0.1/24,   195.39.246.32/28,   2a0f:4ac0:acab::1/64
     local_addresses:
       - /fritz.box/192.168.178.1
-      - /intel-nuc/192.168.178.21
       - /lollo/192.168.178.20
-      - /repo-vm/192.168.178.24
-      - /mastodon-backup/192.168.178.25
-      - /foo-nuc/192.168.178.23
+#      - /intel-nuc/192.168.178.21
+#      - /repo-vm/192.168.178.24
+#      - /mastodon-backup/192.168.178.25
+#      - /foo-nuc/192.168.178.23
     addresses:
       - home.ctu.cx,                        195.39.246.33,   2a0f:4ac0:acab::1
-      - home.flauschekatze.space,           195.39.246.33,   2a0f:4ac0:acab::1
       - legacy.home.ctu.cx,                 195.39.246.33,   2a0f:4ac0:acab::1
-      - legacy.home.flauschekatze.space,    195.39.246.33,   2a0f:4ac0:acab::1
+      - dnsmasq.home.ctu.cx,                195.39.246.33,   2a0f:4ac0:acab::1
+#      - home.flauschekatze.space,           195.39.246.33,   2a0f:4ac0:acab::1
+#      - legacy.home.flauschekatze.space,    195.39.246.33,   2a0f:4ac0:acab::1
     dns_servers:
       - 1.1.1.1
       - 1.0.0.1

@@ -305,3 +314,26 @@ services:
         local_port: 22
         remote_port: 2202
 
+  influxdb:
+    enable: true
+    databases: 
+      - powermeter
+
+  mbusd:
+    enable: true
+    device: modbus0
+    baudrate: 9600
+    mode: 8n1
+    port: 502
+
+  smartied:
+    enable: true
+    configFile: config-files/smartied/config.json
+    nginx:
+      enable: true
+      domain: "home.ctu.cx"
+      sslOnly: true
+      ssl:
+        enable: true
+        cert: "/var/lib/acme-redirect/live/home.ctu.cx/fullchain"
+        privkey: "/var/lib/acme-redirect/live/home.ctu.cx/privkey"
diff --git a/configuration/wanderduene.yml b/configuration/wanderduene.yml
@@ -463,6 +463,16 @@ services:
             'f2k1.de'
           ]
 
+        - job_name: 'smarthome-exporter'
+          metrics_path: '/smarthome-exporter'
+          scheme: 'https'
+          scrape_interval: 30s
+          bearer_token: 'penis123'
+          static_configs:
+          - targets: [
+            'home.ctu.cx'
+          ]
+
   grafana:
     enable: true
     configFile: config-files/grafana/grafana.ini
diff --git a/playbook.yml b/playbook.yml
@@ -96,6 +96,10 @@
   roles: 
     - role: common
       tags: common
+    - role: files
+      tags: files
+    - role: systemd-timers
+      tags: timers
     - role: kawaidesu.ansible_networkd
       tags: systemd-networkd
     - role: acme-redirect

@@ -112,4 +116,10 @@
       tags:
         - frp
         - frpc
-        - frps -
\ No newline at end of file
+        - frps 
+    - role: influxdb
+      tags: influxdb
+    - role: mbusd
+      tags: mbusd
+    - role: smarthome
+      tags: [ smartied, smarthome ]