From 379aaa7d106f091c69af621ee84bfab1659854b6 Mon Sep 17 00:00:00 2001 From: cronekorkn Date: Sun, 4 Feb 2024 11:27:35 +0100 Subject: [PATCH] wip --- bundles/mariadb/items.py | 1 - bundles/wordpress/items.py | 4 ++-- bundles/wordpress/metadata.py | 19 ++++++++++++++++++ data/wordpress/vhost.conf | 37 +++++++++++++++++++++++++++++++++++ nodes/netcup.mails.py | 12 ------------ 5 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 data/wordpress/vhost.conf diff --git a/bundles/mariadb/items.py b/bundles/mariadb/items.py index 2aa5813..71a3cf5 100644 --- a/bundles/mariadb/items.py +++ b/bundles/mariadb/items.py @@ -57,7 +57,6 @@ for db, conf in node.metadata.get('mariadb/databases', {}).items(): f'action:mariadb_user_{db}_create', ], } - print(mariadb(f"SHOW GRANTS FOR {db}") + f" | grep -q '^GRANT ALL PRIVILEGES ON `{db}`.`{db}` TO `{db}`@`%`$'") actions[f'mariadb_grant_privileges_to_{db}'] = { 'command': mariadb(f"GRANT ALL PRIVILEGES ON {db} TO '{db}'", database=db), 'unless': mariadb(f"SHOW GRANTS FOR {db}") + f" | grep -q '^GRANT ALL PRIVILEGES ON `{db}`.`{db}` TO `{db}`@`%`$'", diff --git a/bundles/wordpress/items.py b/bundles/wordpress/items.py index e82bae3..b674aa2 100644 --- a/bundles/wordpress/items.py +++ b/bundles/wordpress/items.py @@ -1,6 +1,6 @@ -for domain, conf in node.metadata.get('wordpress').items(): +for site, conf in node.metadata.get('wordpress').items(): directories = { - f'/opt/wordpress/{domain}': { + f'/opt/wordpress/{site}': { 'owner': 'www-data', 'group': 'www-data', 'mode': '0755', diff --git a/bundles/wordpress/metadata.py b/bundles/wordpress/metadata.py index 6e1219d..7adbbb0 100644 --- a/bundles/wordpress/metadata.py +++ b/bundles/wordpress/metadata.py @@ -29,3 +29,22 @@ def mariadb(metadata): }, }, } + + +@metadata_reactor.provides( + 'nginx/vhosts' +) +def vhost(metadata): + return { + 'nginx': { + 'vhosts': { + conf['domain']: { + 'content': 'wordpress/vhost.conf', + 'context': { + 'root': f'/opt/{site}', + }, + } + for site, conf in metadata.get('wordpress').items() + }, + }, + } diff --git a/data/wordpress/vhost.conf b/data/wordpress/vhost.conf new file mode 100644 index 0000000..146556f --- /dev/null +++ b/data/wordpress/vhost.conf @@ -0,0 +1,37 @@ +# Upstream to abstract backend connection(s) for php +server { + server_name ${server_name}; + root ${root}; + index index.php; + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location / { + # This is cool because no php is touched for static content. + # include the "?$args" part so non-default permalinks doesn't break when using query string + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini + include params/fastcgi; + fastcgi_intercept_errors on; + fastcgi_pass php-handler; + # The following parameter can be also included in fastcgi_params file + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } +} diff --git a/nodes/netcup.mails.py b/nodes/netcup.mails.py index 31dd171..af45e7c 100644 --- a/nodes/netcup.mails.py +++ b/nodes/netcup.mails.py @@ -79,10 +79,6 @@ 'A': ['202.61.255.108'], 'AAAA': ['2a01:4f8:1c1c:4121::1'], }, - 'elimu-kwanza.de': { - 'A': ['202.61.255.108'], - 'AAAA': ['2a01:4f8:1c1c:4121::1'], - }, }, 'download-server': { 'hostname': 'dl.sublimity.de', @@ -178,14 +174,6 @@ }, 'internal_dns': False, }, - 'elimu-kwanza.de': { - 'content': 'nginx/message.conf', - 'context': { - 'title': 'Im Aufbau/under construction', - 'message': 'info@elimu-kwanza.de', - }, - 'internal_dns': False, - }, 'cronekorkn.de': { 'content': 'nginx/redirect.conf', 'context': {