Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add robot action group; use attributes to document module capabilities #65

Merged
merged 5 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/action_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Added a ``community.hrobot.robot`` module defaults group / action group. Use with ``group/community.hrobot.robot`` to provide options for all Hetzner Robot modules (https://github.com/ansible-collections/community.hrobot/pull/65)."
13 changes: 13 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,16 @@
# SPDX-License-Identifier: GPL-3.0-or-later

requires_ansible: '>=2.9.10'
action_groups:
robot:
- boot
- failover_ip
- failover_ip_info
- firewall
- firewall_info
- reset
- reverse_dns
- server
- server_info
- ssh_key
- ssh_key_info
95 changes: 95 additions & 0 deletions plugins/doc_fragments/attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-

# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


class ModuleDocFragment(object):

# Standard documentation fragment
DOCUMENTATION = r'''
options: {}
attributes:
check_mode:
description: Can run in C(check_mode) and return changed status prediction without modifying target.
diff_mode:
description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode.
'''

# Should be used together with the standard fragment
INFO_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
'''

ACTIONGROUP_ROBOT = r'''
options: {}
attributes:
action_group:
description: Use C(group/community.hrobot.robot) in C(module_defaults) to set defaults for this module.
support: full
membership:
- community.hrobot.robot
'''

CONN = r'''
options: {}
attributes:
become:
description: Is usable alongside C(become) keywords.
connection:
description: Uses the target's configured connection information to execute code on it.
delegation:
description: Can be used in conjunction with C(delegate_to) and related keywords.
'''

FACTS = r'''
options: {}
attributes:
facts:
description: Action returns an C(ansible_facts) dictionary that will update existing host facts.
'''

# Should be used together with the standard fragment and the FACTS fragment
FACTS_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
facts:
support: full
'''

FILES = r'''
options: {}
attributes:
safe_file_operations:
description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption.
'''

FLOW = r'''
options: {}
attributes:
action:
description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller.
async:
description: Supports being used with the C(async) keyword.
'''
10 changes: 10 additions & 0 deletions plugins/modules/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
description: Query information on SSH keys
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: none

options:
server_number:
Expand Down
12 changes: 11 additions & 1 deletion plugins/modules/failover_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
- module: community.hrobot.failover_ip_info
description: Retrieve information on failover IPs.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: full

options:
failover_ip:
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/failover_ip_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
- module: community.hrobot.failover_ip
description: Manage failover IPs.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot
- community.hrobot.attributes.info_module

attributes:
action_group:
version_added: 1.6.0

options:
failover_ip:
Expand Down
12 changes: 11 additions & 1 deletion plugins/modules/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@
- module: community.hrobot.firewall_info
description: Retrieve information on firewall configuration.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: full

options:
server_ip:
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/firewall_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
- module: community.hrobot.firewall
description: Configure firewall.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot
- community.hrobot.attributes.info_module

attributes:
action_group:
version_added: 1.6.0

options:
server_ip:
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
- Reset a dedicated server with a software or hardware reset, or by requesting a manual reset.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: none

options:
server_number:
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/reverse_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@
- Allows to set, update or remove a reverse DNS entry for an IP address.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot
notes:
- For the main IPv4 address of a server, deleting it actually sets it to a default hostname like
C(static.X.Y.Z.W.clients.your-server.de). This substitution (delete is replaced by changing to
this value) is done automatically by the API and results in the module not being idempotent
in this case.

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: none

options:
ip:
description:
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
- Right now the API only supports updating the server's name.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: none

options:
server_number:
Expand Down
7 changes: 7 additions & 0 deletions plugins/modules/server_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
- Query information on one or more servers.
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot
- community.hrobot.attributes.info_module

attributes:
action_group:
version_added: 1.6.0

options:
server_number:
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/ssh_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
description: Query information on SSH keys
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot

attributes:
action_group:
version_added: 1.6.0
check_mode:
support: full
diff_mode:
support: none

options:
state:
Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/ssh_key_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
description: Add, remove or update SSH key
extends_documentation_fragment:
- community.hrobot.robot
- community.hrobot.attributes
- community.hrobot.attributes.actiongroup_robot
- community.hrobot.attributes.info_module
attributes:
action_group:
version_added: 1.6.0
'''

EXAMPLES = r'''
Expand Down