Skip to content

Commit

Permalink
Fix sudo after reboot tmp clear (#1033)
Browse files Browse the repository at this point in the history
* cleanup sudo file data

* logic fixed

* Fix `server.reboot` test

---------

Co-authored-by: Nick Mills-Barrett <[email protected]>
  • Loading branch information
stone-w4tch3r and Fizzadar authored Nov 26, 2023
1 parent 84fca9a commit 9256e6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pyinfra/operations/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/operations/server.reboot/reboot.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"command": "reboot",
"success_exit_codes": [0, -1]
},
["wait_and_reconnect", [], {}]
["wait_and_reconnect", [], {}],
["clean_sudo_info", [], {}]
],
"idempotent": false
}

0 comments on commit 9256e6a

Please sign in to comment.