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.operations import server, files
|
||||
from pyinfra.operations import server, files, systemd
|
||||
|
||||
if host.fact.file(host.data.undocker_cache+'/photoprism.tar'):
|
||||
server.shell(
|
||||
name='Remove photoprism Docker image',
|
||||
chdir=host.data.undocker_cache,
|
||||
commands=['rm photoprism.tar'],
|
||||
systemd.service(
|
||||
name='Disable systemd service',
|
||||
service=f"{host.data.app['name']}.service",
|
||||
running=False,
|
||||
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(
|
||||
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