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