From c0df366471e80da8ce4007cef22683ca205b77c3 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Sun, 25 Jan 2026 21:12:19 +0100 Subject: [PATCH] Adding 'project' parameter support for the Scaleway SG module. (#11366) * Adding 'project' parameter support for the Scaleway SG module. * Adding changelog fragment. * Fixing documentation, organization is deprecated (although still available). * Updating docs to show both org and project ID options. * Incrementing version. Co-authored-by: Felix Fontein * Moving deprecated example to the end. --------- Co-authored-by: Felix Fontein --- .../11366-scaleway-sg-project-param.yml | 2 + plugins/modules/scaleway_security_group.py | 38 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/11366-scaleway-sg-project-param.yml diff --git a/changelogs/fragments/11366-scaleway-sg-project-param.yml b/changelogs/fragments/11366-scaleway-sg-project-param.yml new file mode 100644 index 0000000000..41a6887ebb --- /dev/null +++ b/changelogs/fragments/11366-scaleway-sg-project-param.yml @@ -0,0 +1,2 @@ +minor_changes: + - scaleway_security_group - added ``project`` parameter (https://github.com/ansible-collections/community.general/issues/11364, https://github.com/ansible-collections/community.general/pull/11366). diff --git a/plugins/modules/scaleway_security_group.py b/plugins/modules/scaleway_security_group.py index cff684430e..4273fecbaa 100644 --- a/plugins/modules/scaleway_security_group.py +++ b/plugins/modules/scaleway_security_group.py @@ -37,10 +37,10 @@ options: default: present organization: + type: str description: - Organization identifier. - type: str - required: true + - Exactly one of O(project) and O(organization) must be specified. region: description: @@ -95,16 +95,36 @@ options: description: - Create security group to be the default one. type: bool + + project: + type: str + description: + - Project identifier. + - Exactly one of O(project) and O(organization) must be specified. + version_added: 12.3.0 """ EXAMPLES = r""" -- name: Create a Security Group +- name: Create a Security Group using a project ID community.general.scaleway_security_group: state: present region: par1 name: security_group description: "my security group description" - organization: "43a3b6c8-916f-477b-b7ec-ff1898f5fdd9" + stateful: false + inbound_default_policy: accept + outbound_default_policy: accept + organization_default: false + project: 951df375-e094-4d26-97c1-ba548eeb9c42 + register: security_group_creation_task + +- name: Create a Security Group in the default project using an organization ID (deprecated) + community.general.scaleway_security_group: + state: present + region: par1 + name: security_group + description: "my security group description" + organization: 43a3b6c8-916f-477b-b7ec-ff1898f5fdd9 stateful: false inbound_default_policy: accept outbound_default_policy: accept @@ -216,6 +236,7 @@ def core(module): "inbound_default_policy": module.params["inbound_default_policy"], "outbound_default_policy": module.params["outbound_default_policy"], "organization_default": module.params["organization_default"], + "project": module.params["project"], } region = module.params["region"] @@ -234,7 +255,7 @@ def main(): argument_spec.update( dict( state=dict(type="str", default="present", choices=["absent", "present"]), - organization=dict(type="str", required=True), + organization=dict(type="str"), name=dict(type="str", required=True), description=dict(type="str"), region=dict(type="str", required=True, choices=list(SCALEWAY_LOCATION.keys())), @@ -242,12 +263,19 @@ def main(): inbound_default_policy=dict(type="str", choices=["accept", "drop"]), outbound_default_policy=dict(type="str", choices=["accept", "drop"]), organization_default=dict(type="bool"), + project=dict(type="str"), ) ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[["stateful", True, ["inbound_default_policy", "outbound_default_policy"]]], + mutually_exclusive=[ + ("organization", "project"), + ], + required_one_of=[ + ("organization", "project"), + ], ) core(module)