From 55cfd27be99e0b3fe2d324d156445a19d8ad91e7 Mon Sep 17 00:00:00 2001 From: Derek Schrock Date: Mon, 14 Aug 2023 13:41:47 -0400 Subject: [PATCH] freebsd: shutdown -p ... on freebsd to power off machine (#7102) * freebsd: shutdown -p ... on freebsd to power off machine * Use shutdown -p ... on FreeBSD such that the machine is halted and powered off (-p) otherwise the machine is halted (-h) but remains on. * Update changelogs/fragments/7102-freebsd-shutdown-p.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/7102-freebsd-shutdown-p.yml | 2 ++ plugins/action/shutdown.py | 2 +- tests/integration/targets/shutdown/tasks/main.yml | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/7102-freebsd-shutdown-p.yml diff --git a/changelogs/fragments/7102-freebsd-shutdown-p.yml b/changelogs/fragments/7102-freebsd-shutdown-p.yml new file mode 100644 index 0000000000..1a0209cf02 --- /dev/null +++ b/changelogs/fragments/7102-freebsd-shutdown-p.yml @@ -0,0 +1,2 @@ +minor_changes: + - shutdown - use ``shutdown -p ...`` with FreeBSD to halt and power off machine (https://github.com/ansible-collections/community.general/pull/7102). diff --git a/plugins/action/shutdown.py b/plugins/action/shutdown.py index 914aede393..01201a6405 100644 --- a/plugins/action/shutdown.py +++ b/plugins/action/shutdown.py @@ -45,7 +45,7 @@ class ActionModule(ActionBase): SHUTDOWN_COMMAND_ARGS = { 'alpine': '', 'void': '-h +{delay_min} "{message}"', - 'freebsd': '-h +{delay_sec}s "{message}"', + 'freebsd': '-p +{delay_sec}s "{message}"', 'linux': DEFAULT_SHUTDOWN_COMMAND_ARGS, 'macosx': '-h +{delay_min} "{message}"', 'openbsd': '-h +{delay_min} "{message}"', diff --git a/tests/integration/targets/shutdown/tasks/main.yml b/tests/integration/targets/shutdown/tasks/main.yml index f323b8c441..2c9bc6bd6d 100644 --- a/tests/integration/targets/shutdown/tasks/main.yml +++ b/tests/integration/targets/shutdown/tasks/main.yml @@ -77,8 +77,8 @@ - name: Verify shutdown delay is present in seconds in FreeBSD assert: that: - - '"-h +100s" in shutdown_result["shutdown_command"]' - - '"-h +0s" in shutdown_result_minus["shutdown_command"]' + - '"-p +100s" in shutdown_result["shutdown_command"]' + - '"-p +0s" in shutdown_result_minus["shutdown_command"]' when: ansible_system == 'FreeBSD' - name: Verify shutdown delay is present in seconds in Solaris, SunOS