Compare commits

..

1 commit

Author SHA1 Message Date
missytake d99841843c added pyinfra method to deploy wordpress 2024-02-07 16:42:04 +01:00
2 changed files with 12 additions and 26 deletions

View file

@ -5,10 +5,10 @@ StartLimitIntervalSec=0
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/podman run --rm --name={{container_name}} {{environment}} {{mount}} {{port}} docker.io/library/{{container}}:{{version}} ExecStart=/usr/bin/podman run --rm --name={{name}} {{environment}} {{mount}} {{port}} {{container}}:{{version}}
EnvironmentFile=%h/.env
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -15,8 +15,6 @@ def deploy_wordpress(
mysql_root_password: str = None, mysql_root_password: str = None,
_su: dict = {}, _su: dict = {},
): ):
if not mysql_root_password:
mysql_root_password = mysql_password
# check that podman is installed # check that podman is installed
secrets = [ secrets = [
f"MYSQL_PASSWORD={mysql_password}", f"MYSQL_PASSWORD={mysql_password}",
@ -40,21 +38,10 @@ def deploy_wordpress(
"ufw allow 443", "ufw allow 443",
"ufw allow 80", "ufw allow 80",
"ufw allow 22", "ufw allow 22",
"ufw allow 42022",
"ufw status", "ufw status",
# "ufw reload?", # "ufw reload?",
], ],
) )
files.directory(
name="create db_data directory",
path=f"/home/{unix_user}/db_data",
**_su,
)
files.directory(
name="create wp-content directory",
path=f"/home/{unix_user}/wp-content",
**_su,
)
print(importlib.resources.files(__package__)) print(importlib.resources.files(__package__))
service_path = f"/home/{unix_user}/.config/systemd/user/" service_path = f"/home/{unix_user}/.config/systemd/user/"
@ -71,12 +58,12 @@ def deploy_wordpress(
files.template( files.template(
name="upload wordpress systemd service", name="upload wordpress systemd service",
src=importlib.resources.files(__package__) / "podman.service.j2", src=importlib.resources.files(__package__) / "podman.service.j2",
dest=f"{service_path}{domain}_wp.service", dest=f"{service_path}wordpress.service",
description="run wordpress podman container", description="run wordpress podman container",
container_name=f"{domain}_wp", name=f"{domain}_wp",
environment="-e " + "-e ".join(environment), environment="-e " + "-e ".join(environment),
mount="--mount " + "--mount ".join(mount), mount="--mount " + "--mount ".join(mount),
port=f"-p 127.0.0.1:{wordpress_port}:80", port=f"-p 127.0.0.1:{nginx_port}:80"
container="wordpress", container="wordpress",
version=wordpress_version, version=wordpress_version,
**_su, **_su,
@ -91,12 +78,12 @@ def deploy_wordpress(
files.template( files.template(
name="upload mysql systemd service", name="upload mysql systemd service",
src=importlib.resources.files(__package__) / "podman.service.j2", src=importlib.resources.files(__package__) / "podman.service.j2",
dest=f"{service_path}{domain}_db.service", dest=f"{service_path}mysql.service",
description="run mysql podman container", description="run mysql podman container",
container_name=f"{domain}_db", name=f"{domain}_db",
environment="-e " + "-e ".join(environment), environment="-e " + "-e ".join(environment),
mount=f"--mount type=bind,source=/home/{unix_user}/db_data,destination=/var/lib/mysql", mount=f"--mount type=bind,source=/home/{unix_user}/db_data/_data/,destination=/var/lib/mysql",
port=f"-p {mysql_port}:3306", port=f"-p {mysql_port}:3306"
container="mysql", container="mysql",
version="5.7", version="5.7",
**_su, **_su,
@ -119,5 +106,4 @@ def deploy_wordpress(
daemon_reload=True, daemon_reload=True,
user_name=unix_user, user_name=unix_user,
user_mode=True, user_mode=True,
**_su,
) )