mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
chore: Use volume key for both volume name and id
This commit is contained in:
parent
ba4a2a6afe
commit
908162d396
1 changed files with 4 additions and 13 deletions
|
|
@ -20,14 +20,11 @@ author:
|
|||
- Amirhossein Shaerpour (@shaerpour)
|
||||
|
||||
options:
|
||||
id:
|
||||
description:
|
||||
- ID of the volume
|
||||
type: int
|
||||
volume:
|
||||
description:
|
||||
- Name of the volume
|
||||
type: str
|
||||
required: true
|
||||
server:
|
||||
description:
|
||||
- Server name where volume will be assigned to
|
||||
|
|
@ -65,7 +62,7 @@ EXAMPLES = """
|
|||
|
||||
- name: Attach my-volume using id to my-server with automount enabled
|
||||
hetzner.hcloud.server_volume:
|
||||
id: 123456
|
||||
volume: "123456"
|
||||
server: my-server
|
||||
state: attached
|
||||
automount: true
|
||||
|
|
@ -111,10 +108,7 @@ class AnsibleHCloudServerVolume(AnsibleHCloud):
|
|||
|
||||
def _get_server_and_volume(self):
|
||||
try:
|
||||
if self.module.params.get("id") is not None:
|
||||
self.hcloud_server_volume = self._client_get_by_name_or_id("volumes", self.module.params.get("id"))
|
||||
else:
|
||||
self.hcloud_server_volume = self._client_get_by_name_or_id("volumes", self.module.params.get("volume"))
|
||||
self.hcloud_server_volume = self._client_get_by_name_or_id("volumes", self.module.params.get("volume"))
|
||||
|
||||
self.hcloud_server = self._client_get_by_name_or_id(
|
||||
"servers",
|
||||
|
|
@ -152,8 +146,7 @@ class AnsibleHCloudServerVolume(AnsibleHCloud):
|
|||
def define_module(cls):
|
||||
return AnsibleModule(
|
||||
argument_spec=dict(
|
||||
id={"type": "int"},
|
||||
volume={"type": "str"},
|
||||
volume={"type": "str", "required": True},
|
||||
server={"type": "str", "required": True},
|
||||
automount={"type": "bool", "default": False},
|
||||
state={
|
||||
|
|
@ -162,8 +155,6 @@ class AnsibleHCloudServerVolume(AnsibleHCloud):
|
|||
},
|
||||
**super().base_module_arguments(),
|
||||
),
|
||||
required_one_of=[["id", "volume"]],
|
||||
mutually_exclusive=[["id", "volume"]],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue