]> gitweb.hamatoma.de Git - ansknife.git/commitdiff
Improvements
authorHamatoma <author@hamatoma.de>
Mon, 19 May 2025 13:15:16 +0000 (15:15 +0200)
committerHamatoma <author@hamatoma.de>
Mon, 19 May 2025 13:15:16 +0000 (15:15 +0200)
docu/de/70_postgresql.md
docu/de/71_mysql.md [new file with mode: 0644]
playbooks.templates/i_17_configuration.yaml
playbooks.templates/mysql_users.yaml
templates.vars/common.yaml

index d385320438339fd63c957f4dcfad6e54233a3cc6..78ec9625dfdd8e83bf287f90f27d5bc664ddf5d6 100644 (file)
@@ -48,4 +48,20 @@ CREATE ROLE mydb WITH CREATEDB CREATEROLE NOLOGIN;
 CREATE DATABASE mydb OWNER = mydb;
 # Zugriff von Benutzer Jonny auf mydb:
 GRANT mydb TO jonny;
+```
+
+### Dump und Restore
+- effizent, aber nicht abwärtskompatibel: -F c
+- ab- und aufwärtskompatibel: -F p
+```
+pg_dump -U postgres -d datenbankname -F p -f backup.sql
+
+# Auf dem alten Server (PostgreSQL 13):
+pg_dump -U postgres -F c -f meine_db.dump meine_db
+
+# Datei auf neuen Server kopieren
+
+# Auf dem neuen Server (PostgreSQL 15):
+createdb -U postgres meine_db
+pg_restore -U postgres -d meine_db meine_db.dump
 ```
\ No newline at end of file
diff --git a/docu/de/71_mysql.md b/docu/de/71_mysql.md
new file mode 100644 (file)
index 0000000..349efea
--- /dev/null
@@ -0,0 +1,26 @@
+# MySql
+
+## Zielsetzung
+Hier wird beschrieben, wie die Datenbank- und Rechteverwaltung unter Maraiadb bzw. MySql funktioniert.
+
+## Rechtemanagement
+Benutzer werden in der DB mysql definiert:
+```
+mysql -u root -p mysql
+```
+
+## Einrichten eines Superusers mit Zugriff auf alles
+```
+CREATE USER 'dba'@'localhost' IDENTIFIED BY 'topsecret';
+GRANT ALL PRIVILEGES ON *.* TO 'dba'@'localhost' WITH GRANT OPTION;
+
+CREATE USER 'dba'@'10.10.100.171' IDENTIFIED BY 'topsecret';
+GRANT ALL PRIVILEGES ON *.* TO 'dba'@'10.10.100.171' WITH GRANT OPTION;
+FLUSH PRIVILEGES;
+```
+
+# Abfrage der Benutzer und Rechte
+```
+select host, user from user;
+show grants for 'dba'@'localhost';
+```
index 76bbe092a876af7efcfbbe324e61d5d2412ce601..afbe9c9cf26ff23230aa3836a05f62f3d490dc2d 100644 (file)
         line: SystemMaxFileSize={{ systemd_journal_system_max_file_size }}
       notify:
         - restart systemd-journald
+    - name: Avoid SSH session timeout
+      ansible.builtin.lineinfile:
+        dest: /etc/ssh/sshd_config
+        regexp: "^#?{{ item.key }}"
+        line: "{{ item.key }} {{ item.value }}"
+      notify:
+        - restart sshd
+      with_dict:
+        ClientAliveInterval: "{{ ssh_alive_interval }}"
+        ClientAliveCountMax: "{{ ssh_alive_max_count }}"
   handlers:
     - name: restart systemd-journald
       ansible.builtin.systemd:
         name: systemd-journald
+        state: restarted
+    - name: restart sshd
+      ansible.builtin.systemd:
+        name: sshd
         state: restarted
\ No newline at end of file
index d38294ed78211b851b4987ecc8ede943d5fe6ab9..d538936eb0c9711b76dbdb06ffad115c1aa4fa49 100644 (file)
@@ -10,6 +10,7 @@
         name: "{{ item.name }}"
         password: "{{ item.password }}"
         host: "{{ item.host }}"
+        priv: "{{ item.db }}.*:ALL,GRANT"
         state: present
         login_user: "{{ dba_name }}"
         login_password: "{{ dba_password }}"
@@ -20,6 +21,7 @@
       ansible.builtin.mysql_user:
         name: "{{ item.name }}"
         host: "{{ item.host }}"
+        priv: "{{ item.db }}.*:ALL,GRANT"
         state: present
         login_user: "{{ dba_name }}"
         login_password: "{{ dba_password }}"
index 1a8c9c12288c6459b68c32626b0624c819ce0539..1a50880e22fa0def8d112032eb7815a499020eeb 100644 (file)
@@ -5,6 +5,8 @@ remote_www_directory: "/home/www"
 # the system log files have maximal that size
 systemd_journal_system_max_use: 200M
 systemd_journal_system_max_file_size: 50M
+ssh_alive_interval: 60
+ssh_alive_max_count: 3
 postfix_host: "mail.example.com"
 postfix_domain: "example.com"
 postfix_mode: send_only