26 lines
695 B
Python
26 lines
695 B
Python
from pyinfra import host
|
|
from pyinfra.operations import server, files, systemd
|
|
|
|
systemd.service(
|
|
name='Disable systemd service',
|
|
service=f"{host.data.app['name']}.service",
|
|
running=False,
|
|
enabled=False,
|
|
)
|
|
|
|
if host.fact.file(f"{host.data.undocker['cache']}/{host.data.app['name']}.tar"):
|
|
server.shell(
|
|
name='Remove Docker image',
|
|
chdir=host.data.undocker['cache'],
|
|
commands=[
|
|
f"rm {host.data.app['name']}.tar"
|
|
],
|
|
)
|
|
|
|
if host.fact.directory(f"{host.data.undocker['app_dst']}"):
|
|
server.shell(
|
|
name='Remove undocker destination',
|
|
commands=[
|
|
f"rm -rf {host.data.undocker['app_dst']}"
|
|
],
|
|
)
|