mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-21 20:59:10 +00:00
Merge f49dc75667 into b4336659f6
This commit is contained in:
commit
bb36a0df36
16 changed files with 77 additions and 15 deletions
2
changelogs/fragments/11351-scaleway-ip-info.yml
Normal file
2
changelogs/fragments/11351-scaleway-ip-info.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
deprecated_features:
|
||||||
|
- scaleway_ip_info plugin - use of ``region`` is deprecated and will be disallowed in ``community.general`` 14.0.0 (https://github.com/ansible-collections/community.general/issues/11351).
|
||||||
|
|
@ -255,7 +255,6 @@ class Scaleway:
|
||||||
|
|
||||||
def send(self, method, path, data=None, headers=None, params=None):
|
def send(self, method, path, data=None, headers=None, params=None):
|
||||||
url = self._url_builder(path=path, params=params)
|
url = self._url_builder(path=path, params=params)
|
||||||
self.warn(url)
|
|
||||||
|
|
||||||
if headers is not None:
|
if headers is not None:
|
||||||
self.headers.update(headers)
|
self.headers.update(headers)
|
||||||
|
|
@ -461,6 +460,7 @@ SCALEWAY_REGIONS = [
|
||||||
"fr-par",
|
"fr-par",
|
||||||
"nl-ams",
|
"nl-ams",
|
||||||
"pl-waw",
|
"pl-waw",
|
||||||
|
"it-mil"
|
||||||
]
|
]
|
||||||
|
|
||||||
SCALEWAY_ZONES = [
|
SCALEWAY_ZONES = [
|
||||||
|
|
@ -473,4 +473,5 @@ SCALEWAY_ZONES = [
|
||||||
"pl-waw-1",
|
"pl-waw-1",
|
||||||
"pl-waw-2",
|
"pl-waw-2",
|
||||||
"pl-waw-3",
|
"pl-waw-3",
|
||||||
|
"it-mil-1"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ options:
|
||||||
- fr-par
|
- fr-par
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
name:
|
name:
|
||||||
type: str
|
type: str
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ options:
|
||||||
region:
|
region:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
- Scaleway region to use (for example C(par1)).
|
- Scaleway region to use (for example C(par1)) (deprecated).
|
||||||
required: true
|
required: false
|
||||||
choices:
|
choices:
|
||||||
- ams1
|
- ams1
|
||||||
- EMEA-NL-EVS
|
- EMEA-NL-EVS
|
||||||
|
|
@ -44,16 +44,38 @@ options:
|
||||||
- EMEA-PL-WAW1
|
- EMEA-PL-WAW1
|
||||||
- waw2
|
- waw2
|
||||||
- waw3
|
- waw3
|
||||||
|
|
||||||
|
zone:
|
||||||
|
type: str
|
||||||
|
description:
|
||||||
|
- Scaleway zone to use (for example (nl-ams-1))
|
||||||
|
required: false
|
||||||
|
choices:
|
||||||
|
- fr-par-1
|
||||||
|
- fr-par-2
|
||||||
|
- fr-par-3
|
||||||
|
- nl-ams-1
|
||||||
|
- nl-ams-2
|
||||||
|
- nl-ams-3
|
||||||
|
- pl-waw-1
|
||||||
|
- pl-waw-2
|
||||||
|
- pl-waw-3
|
||||||
|
- it-mil-1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
- name: Gather Scaleway IPs information
|
- name: Gather Scaleway IPs information
|
||||||
community.general.scaleway_ip_info:
|
community.general.scaleway_ip_info:
|
||||||
region: par1
|
zone: fr-par-1
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- ansible.builtin.debug:
|
||||||
msg: "{{ result.scaleway_ip_info }}"
|
msg: "{{ result.scaleway_ip_info }}"
|
||||||
|
|
||||||
|
- name: Gather Scaleway IPs information (deprecated)
|
||||||
|
community.general.scaleway_ip_info:
|
||||||
|
region: par-1
|
||||||
|
register: result
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
|
|
@ -83,6 +105,8 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||||
SCALEWAY_LOCATION,
|
SCALEWAY_LOCATION,
|
||||||
|
SCALEWAY_ENDPOINT,
|
||||||
|
SCALEWAY_ZONES,
|
||||||
Scaleway,
|
Scaleway,
|
||||||
ScalewayException,
|
ScalewayException,
|
||||||
scaleway_argument_spec,
|
scaleway_argument_spec,
|
||||||
|
|
@ -94,26 +118,49 @@ class ScalewayIpInfo(Scaleway):
|
||||||
super().__init__(module)
|
super().__init__(module)
|
||||||
self.name = "ips"
|
self.name = "ips"
|
||||||
|
|
||||||
region = module.params["region"]
|
if self.module.params.get("zone"):
|
||||||
self.module.params["api_url"] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
self.module.params["api_url"] = SCALEWAY_ENDPOINT
|
||||||
|
else:
|
||||||
|
self.module.params["api_url"] = SCALEWAY_LOCATION[self.module.params.get("region")]["api_endpoint"]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = scaleway_argument_spec()
|
argument_spec = scaleway_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
dict(
|
dict(
|
||||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
region=dict(required=False, choices=list(SCALEWAY_LOCATION.keys())),
|
||||||
|
zone=dict(required=False, choices=list(SCALEWAY_ZONES)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
|
mutually_exclusive=[
|
||||||
|
("zone", "region"),
|
||||||
|
],
|
||||||
|
required_one_of=[
|
||||||
|
("zone", "region"),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
api = ScalewayIpInfo(module=module)
|
||||||
module.exit_json(scaleway_ip_info=ScalewayIpInfo(module).get_resources())
|
|
||||||
except ScalewayException as exc:
|
if module.params["zone"]:
|
||||||
module.fail_json(msg=exc.message)
|
zone = module.params["zone"]
|
||||||
|
api_path = f"instance/v1/zones/{zone}/ips"
|
||||||
|
response = scaleway_ip_info=api.get(path=api_path)
|
||||||
|
module.exit_json(scaleway_ip_info=response.json.get('ips'))
|
||||||
|
else:
|
||||||
|
module.deprecate(
|
||||||
|
msg="The 'region' parameter is deprecated. Use 'zone' to specify the Scaleway zone instead.",
|
||||||
|
version="14.0.0",
|
||||||
|
collection_name="community.general",
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
module.exit_json(scaleway_ip_info=ScalewayIpInfo(module).get_resources())
|
||||||
|
except ScalewayException as exc:
|
||||||
|
module.fail_json(msg=exc.message)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ options:
|
||||||
- nl-ams
|
- nl-ams
|
||||||
- fr-par
|
- fr-par
|
||||||
- pl-waw
|
- pl-waw
|
||||||
|
- it-mil
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
type: list
|
type: list
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
- name: Get ip information and register it in a variable
|
- name: Get ip information and register it in a variable
|
||||||
scaleway_ip_info:
|
community.general.scaleway_ip_info:
|
||||||
region: par1
|
zone: nl-ams-1
|
||||||
register: ips
|
register: ips
|
||||||
|
|
||||||
- name: Display ips variable
|
- name: Display ips variable
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
- ips is success
|
- ips is success
|
||||||
|
|
||||||
- name: Get ip information and register it in a variable
|
- name: Get ip information and register it in a variable
|
||||||
scaleway_ip_info:
|
community.general.scaleway_ip_info:
|
||||||
region: ams1
|
zone: nl-ams-1
|
||||||
register: ips_ams1
|
register: ips_ams1
|
||||||
|
|
||||||
- name: Display ips variable
|
- name: Display ips variable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue