Debian Codegraph @

ansible_collections/community/general/plugins/modules/shutdown.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2020, Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: shutdown
10 short_description: Shut down a machine
11 notes:
12 - E(PATH) is ignored on the remote node when searching for the C(shutdown) command. Use O(search_paths) to specify locations
13 to search if the default paths do not work.
14 - The O(msg) and O(delay) options are not supported when a shutdown command is not found in O(search_paths), instead the
15 module attempts to shutdown the system by calling C(systemctl shutdown).
16 description:
17 - Shut downs a machine.
18 version_added: "1.1.0"
19 extends_documentation_fragment:
20 - community.general._attributes
21 - community.general._attributes.flow
22 attributes:
23 check_mode:
24 support: full
25 diff_mode:
26 support: none
27 action:
28 support: full
29 async:
30 support: full
31 options:
32 delay:
33 description:
34 - Seconds to wait before shutdown. Passed as a parameter to the shutdown command.
35 - On Linux, macOS and OpenBSD, this is converted to minutes and rounded down. If less than 60, it is set to 0.
36 - On Solaris and FreeBSD, this represents seconds.
37 type: int
38 default: 0
39 msg:
40 description:
41 - Message to display to users before shutdown.
42 type: str
43 default: Shut down initiated by Ansible
44 search_paths:
45 description:
46 - Paths to search on the remote machine for the C(shutdown) command.
47 - I(Only) these paths are searched for the C(shutdown) command. E(PATH) is ignored in the remote node when searching
48 for the C(shutdown) command.
49 type: list
50 elements: path
51 default: ['/sbin', '/usr/sbin', '/usr/local/sbin']
52
53 seealso:
54 - module: ansible.builtin.reboot
55 author:
56 - Matt Davis (@nitzmahone)
57 - Sam Doran (@samdoran)
58 - Amin Vakil (@aminvakil)
59 """
60
61 EXAMPLES = r"""
62 - name: Unconditionally shut down the machine with all defaults
63 community.general.shutdown:
64
65 - name: Delay shutting down the remote node
66 community.general.shutdown:
67 delay: 60
68
69 - name: Shut down a machine with shutdown command in unusual place
70 community.general.shutdown:
71 search_paths:
72 - '/lib/molly-guard'
73 """
74
75 RETURN = r"""
76 shutdown:
77 description: V(true) if the machine has been shut down.
78 returned: always
79 type: bool
80 sample: true
81 """