diff --git a/pyinfra/operations/server.py b/pyinfra/operations/server.py index 9264dd8b6..d51f2ee63 100644 --- a/pyinfra/operations/server.py +++ b/pyinfra/operations/server.py @@ -99,6 +99,12 @@ def wait_and_reconnect(state, host): # pragma: no cover yield FunctionCommand(wait_and_reconnect, (), {}) + # On certain systems sudo files are lost on reboot + def clean_sudo_info(state, host): + host.connector_data["sudo_askpass_path"] = None + + yield FunctionCommand(clean_sudo_info, (), {}) + @operation(is_idempotent=False) def wait(port: int): diff --git a/tests/operations/server.reboot/reboot.json b/tests/operations/server.reboot/reboot.json index 061a5798d..9b8f5b216 100644 --- a/tests/operations/server.reboot/reboot.json +++ b/tests/operations/server.reboot/reboot.json @@ -6,7 +6,8 @@ "command": "reboot", "success_exit_codes": [0, -1] }, - ["wait_and_reconnect", [], {}] + ["wait_and_reconnect", [], {}], + ["clean_sudo_info", [], {}] ], "idempotent": false }