community.general.shutdown (8.5.0) — module

Shut down a machine

| "added in version" 1.1.0 of community.general"

Authors: Matt Davis (@nitzmahone), Sam Doran (@samdoran), Amin Vakil (@aminvakil)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Shut downs a machine.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Unconditionally shut down the machine with all defaults
  community.general.shutdown:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delay shutting down the remote node
  community.general.shutdown:
    delay: 60
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Shut down a machine with shutdown command in unusual place
  community.general.shutdown:
    search_paths:
     - '/lib/molly-guard'

Inputs

    
msg:
    default: Shut down initiated by Ansible
    description:
    - Message to display to users before shutdown.
    type: str

delay:
    default: 0
    description:
    - Seconds to wait before shutdown. Passed as a parameter to the shutdown command.
    - On Linux, macOS and OpenBSD, this is converted to minutes and rounded down. If less
      than 60, it will be set to 0.
    - On Solaris and FreeBSD, this will be seconds.
    type: int

search_paths:
    default:
    - /sbin
    - /usr/sbin
    - /usr/local/sbin
    description:
    - Paths to search on the remote machine for the C(shutdown) command.
    - I(Only) these paths will be searched for the C(shutdown) command. E(PATH) is ignored
      in the remote node when searching for the C(shutdown) command.
    elements: path
    type: list

Outputs

shutdown:
  description: V(true) if the machine has been shut down.
  returned: always
  sample: true
  type: bool

See also