pyinfra: avoid KeyError if user/service doesn't exist yet
This commit is contained in:
parent
69047ea6e3
commit
89e4bc2873
|
@ -86,9 +86,10 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
)
|
)
|
||||||
|
|
||||||
services = host.get_fact(SystemdStatus, user_mode=True, user_name=unix_user, _su_user=unix_user, _use_su_login=True)
|
services = host.get_fact(SystemdStatus, user_mode=True, user_name=unix_user, _su_user=unix_user, _use_su_login=True)
|
||||||
|
try:
|
||||||
if services['teams-bot.service']:
|
if services['teams-bot.service']:
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name=f"{unix_user}: retart systemd service",
|
name=f"{unix_user}: restart teams-bot systemd service",
|
||||||
service='teams-bot.service',
|
service='teams-bot.service',
|
||||||
running=True,
|
running=True,
|
||||||
restarted=True,
|
restarted=True,
|
||||||
|
@ -96,3 +97,5 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
_su_user=unix_user,
|
_su_user=unix_user,
|
||||||
_use_su_login=True,
|
_use_su_login=True,
|
||||||
)
|
)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in a new issue