ctucx.git: ansible-configs

My personal ansible roles and playbooks

commit c3b03419b6a3a0ab787acdc682542dee6af2c8eb
parent 9cacca7e1808aca56bc293049b524d31acdd0d12
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 21 Feb 2021 16:27:44 +0100

Rename role smarthome to smartied
12 files changed, 88 insertions(+), 50 deletions(-)
diff --git a/roles/openssh/templates/nftables-rule.nft.j2 b/roles/openssh/templates/nftables-rule.nft.j2
@@ -0,0 +1,11 @@
+#!/usr/sbin/nft -f
+#
+# !!! This file is managed by Ansible !!!
+#
+
+table inet firewall {
+    chain inbound {
+        # Allow openssh.
+        tcp dport {{ services.openssh.port | default(22) }} accept comment "openssh"
+    }
+}+
\ No newline at end of file
diff --git a/roles/smarthome/tasks/checks.yml b/roles/smarthome/tasks/checks.yml
@@ -1,43 +0,0 @@
----
-
-- fail: msg="This role currently only supports ArchLinux!"
-  when:
-    - ansible_distribution != "Archlinux" 
-
-- fail: msg="This Role only works when Option 'system.enableOwnRepos' is true!"
-  when:
-    - system.enableOwnRepos is false
-
-
-- fail: msg="Option 'services.smartied.configFile' has to be set!"
-  when:
-    - services.smartied.configFile is not defined
-
-
-- fail: msg="Option 'services.smartied.nginx.domain' has to be set when using nginx!"
-  when:
-    - services.smartied.nginx.enable is defined
-    - services.smartied.nginx.enable is true
-    - services.smartied.nginx.domain is not defined
-
-- fail: msg="Option 'services.smartied.nginx.sslOnly' has to be set when using nginx!"
-  when:
-    - services.smartied.nginx.enable is defined
-    - services.smartied.nginx.enable is true
-    - services.smartied.nginx.sslOnly is not defined
-
-- fail: msg="Option 'services.smartied.nginx.ssl.cert' has to be set when using nginx with ssl!"
-  when:
-    - services.smartied.nginx.enable is defined
-    - services.smartied.nginx.enable is true
-    - services.smartied.nginx.ssl.enable is defined
-    - services.smartied.nginx.ssl.enable is true
-    - services.smartied.nginx.ssl.cert is not defined
-
-- fail: msg="Option 'services.smartied.nginx.ssl.privkey' has to be set when using nginx with ssl!"
-  when:
-    - services.smartied.nginx.enable is defined
-    - services.smartied.nginx.enable is true
-    - services.smartied.nginx.ssl.enable is defined
-    - services.smartied.nginx.ssl.enable is true
-    - services.smartied.nginx.ssl.privkey is not defined
diff --git a/roles/smarthome/tasks/configure.yml b/roles/smarthome/tasks/configure.yml
@@ -1,7 +0,0 @@
----
-
-- name: "Copy config-file to: /etc/smartied.json"
-  copy: 
-    src: "{{ services.smartied.configFile }}"
-    dest: /etc/smartied.json
-    mode: 0755
diff --git a/roles/smartied/files/smartied.service-override.conf b/roles/smartied/files/smartied.service-override.conf
@@ -0,0 +1,7 @@
+#
+# !!! This file is managed by Ansible !!!
+#
+
+[Unit]
+Requires=network.target serial2tcp@tempsensors0.service mbusd@modbus0.service mosquitto.service zigbee2mqtt.service influxdb.service
+After=serial2tcp@tempsensors0.service mbusd@modbus0.service mosquitto.service zigbee2mqtt.service influxdb.service+
\ No newline at end of file
diff --git a/roles/smartied/tasks/checks.yml b/roles/smartied/tasks/checks.yml
@@ -0,0 +1,48 @@
+---
+
+- fail: msg="This role currently only supports ArchLinux!"
+  when:
+    - ansible_distribution != "Archlinux" 
+
+- fail: msg="This Role only works when Option 'system.enableOwnRepos' is true!"
+  when:
+    - system.enableOwnRepos is false
+
+
+- fail: msg="Option 'services.smartied.configFile' has to be set!"
+  when:
+    - services.smartied.configFile is not defined
+
+
+- fail: msg="Nginx role has to be enabled when using nginx options!"
+  when:
+    - services.smartied.nginx.enable is true
+    - services.nginx.enable is false
+
+- fail: msg="Option 'services.smartied.nginx.domain' has to be set when using nginx!"
+  when:
+    - services.smartied.nginx.enable is defined
+    - services.smartied.nginx.enable is true
+    - services.smartied.nginx.domain is not defined
+
+- fail: msg="Option 'services.smartied.nginx.sslOnly' has to be set when using nginx!"
+  when:
+    - services.smartied.nginx.enable is defined
+    - services.smartied.nginx.enable is true
+    - services.smartied.nginx.sslOnly is not defined
+
+- fail: msg="Option 'services.smartied.nginx.ssl.cert' has to be set when using nginx with ssl!"
+  when:
+    - services.smartied.nginx.enable is defined
+    - services.smartied.nginx.enable is true
+    - services.smartied.nginx.ssl.enable is defined
+    - services.smartied.nginx.ssl.enable is true
+    - services.smartied.nginx.ssl.cert is not defined
+
+- fail: msg="Option 'services.smartied.nginx.ssl.privkey' has to be set when using nginx with ssl!"
+  when:
+    - services.smartied.nginx.enable is defined
+    - services.smartied.nginx.enable is true
+    - services.smartied.nginx.ssl.enable is defined
+    - services.smartied.nginx.ssl.enable is true
+    - services.smartied.nginx.ssl.privkey is not defined
diff --git a/roles/smartied/tasks/configure.yml b/roles/smartied/tasks/configure.yml
@@ -0,0 +1,19 @@
+---
+
+- name: "Copy config-file to: /etc/smartied.json"
+  copy: 
+    src: "{{ services.smartied.configFile }}"
+    dest: /etc/smartied.json
+    mode: 0755
+
+- name: "Create directory: /etc/systemd/system/smartied.service.d"
+  file:
+    state: directory
+    dest: /etc/systemd/system/smartied.service.d
+    mode: 0755
+
+- name: Create systemd.service override for smartied
+  copy:
+    src: smartied.service-override.conf
+    dest: /etc/systemd/system/smartied.service.d/override.conf
+    mode: 0755+
\ No newline at end of file
diff --git a/roles/smarthome/tasks/install.yml b/roles/smartied/tasks/install.yml
diff --git a/roles/smarthome/tasks/main.yml b/roles/smartied/tasks/main.yml
diff --git a/roles/smarthome/tasks/nginx.yml b/roles/smartied/tasks/nginx.yml
diff --git a/roles/smarthome/tasks/remove.yml b/roles/smartied/tasks/remove.yml
diff --git a/roles/smarthome/tasks/start.yml b/roles/smartied/tasks/start.yml
diff --git a/roles/smarthome/templates/nginx-vhost.conf.j2 b/roles/smartied/templates/nginx-vhost.conf.j2