Implement remove.py

This commit is contained in:
Benoit S 2021-11-20 11:51:50 +09:00
parent e0339956a2
commit 4e98561b0d

View file

@ -1,16 +1,26 @@
from pyinfra import host
from pyinfra.operations import server, files
from pyinfra.operations import server, files, systemd
if host.fact.file(host.data.undocker_cache+'/photoprism.tar'):
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 photoprism Docker image',
chdir=host.data.undocker_cache,
commands=['rm photoprism.tar'],
name='Remove Docker image',
chdir=host.data.undocker['cache'],
commands=[
f"rm {host.data.app['name']}.tar"
],
)
if host.fact.directory(host.data.undocker_dst):
if host.fact.directory(f"{host.data.undocker['app_dst']}"):
server.shell(
name='Remove undocker destination',
commands=['rm -rf {}'.format(host.data.undocker_dst)],
commands=[
f"rm -rf {host.data.undocker['app_dst']}"
],
)