This repository has been archived on 2023-02-05. You can view files and clone it, but cannot push or open issues or pull requests.
pyinfra-linkding/remove.py

27 lines
695 B
Python
Raw Normal View History

2021-11-15 13:23:45 +00:00
from pyinfra import host
2021-11-20 02:51:50 +00:00
from pyinfra.operations import server, files, systemd
2021-11-15 13:23:45 +00:00
2021-11-20 02:51:50 +00:00
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"):
2021-11-15 13:23:45 +00:00
server.shell(
2021-11-20 02:51:50 +00:00
name='Remove Docker image',
chdir=host.data.undocker['cache'],
commands=[
f"rm {host.data.app['name']}.tar"
],
2021-11-15 13:23:45 +00:00
)
2021-11-20 02:51:50 +00:00
if host.fact.directory(f"{host.data.undocker['app_dst']}"):
2021-11-15 13:23:45 +00:00
server.shell(
name='Remove undocker destination',
2021-11-20 02:51:50 +00:00
commands=[
f"rm -rf {host.data.undocker['app_dst']}"
],
2021-11-15 13:23:45 +00:00
)