Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
missytake | e7a7aaeb37 |
|
@ -5,10 +5,10 @@ StartLimitIntervalSec=0
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/bin/podman run --rm --name={{name}} {{environment}} {{mount}} {{port}} {{container}}:{{version}}
|
ExecStart=/usr/bin/podman run --rm --name={{container_name}} {{environment}} {{mount}} {{port}} docker.io/library/{{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
|
||||||
|
|
||||||
|
|
28
pyinfra.py
28
pyinfra.py
|
@ -15,6 +15,8 @@ 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}",
|
||||||
|
@ -38,10 +40,21 @@ 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/"
|
||||||
|
@ -58,12 +71,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}wordpress.service",
|
dest=f"{service_path}{domain}_wp.service",
|
||||||
description="run wordpress podman container",
|
description="run wordpress podman container",
|
||||||
name=f"{domain}_wp",
|
container_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:{nginx_port}:80"
|
port=f"-p 127.0.0.1:{wordpress_port}:80",
|
||||||
container="wordpress",
|
container="wordpress",
|
||||||
version=wordpress_version,
|
version=wordpress_version,
|
||||||
**_su,
|
**_su,
|
||||||
|
@ -78,12 +91,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}mysql.service",
|
dest=f"{service_path}{domain}_db.service",
|
||||||
description="run mysql podman container",
|
description="run mysql podman container",
|
||||||
name=f"{domain}_db",
|
container_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/_data/,destination=/var/lib/mysql",
|
mount=f"--mount type=bind,source=/home/{unix_user}/db_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,
|
||||||
|
@ -106,4 +119,5 @@ def deploy_wordpress(
|
||||||
daemon_reload=True,
|
daemon_reload=True,
|
||||||
user_name=unix_user,
|
user_name=unix_user,
|
||||||
user_mode=True,
|
user_mode=True,
|
||||||
|
**_su,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue