Implement remove.py
This commit is contained in:
parent
e0339956a2
commit
4e98561b0d
1 changed files with 18 additions and 8 deletions
28
remove.py
28
remove.py
|
@ -1,16 +1,26 @@
|
||||||
from pyinfra import host
|
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(
|
||||||
server.shell(
|
name='Disable systemd service',
|
||||||
name='Remove photoprism Docker image',
|
service=f"{host.data.app['name']}.service",
|
||||||
chdir=host.data.undocker_cache,
|
running=False,
|
||||||
commands=['rm photoprism.tar'],
|
enabled=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
if host.fact.directory(host.data.undocker_dst):
|
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(
|
server.shell(
|
||||||
name='Remove undocker destination',
|
name='Remove undocker destination',
|
||||||
commands=['rm -rf {}'.format(host.data.undocker_dst)],
|
commands=[
|
||||||
|
f"rm -rf {host.data.undocker['app_dst']}"
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Reference in a new issue