Skip to content

Scaleway ip info#11629

Open
philipnorton42 wants to merge 16 commits intoansible-collections:mainfrom
codeenigma:scaleway_ip_info
Open

Scaleway ip info#11629
philipnorton42 wants to merge 16 commits intoansible-collections:mainfrom
codeenigma:scaleway_ip_info

Conversation

@philipnorton42
Copy link
Copy Markdown

SUMMARY

Following on from discussions in the ticket #11351 I have refactored the main scaleway.py class and the scaleway_ip_info module to use "zone" ID, rather than zone names over the old "region" argument. In addition, it's best to move to a system where the URL is constructed, rather than hard coded.

I have added some logic (through annotations) to allow either zone or region to be used, region still functions in the same way as it always has, but will now issue a deprecation warning.

Since the IP info module is a information only module I've selected this as the starting point for refactoring the scaleway modules in this project. They all use different styles of code and make use of the aforemenionted hard coded URLs list.

Whilst I was there, I've also added the new zone that Scaleway have to the main scaleway.py class.

ISSUE TYPE
  • Refactoring Pull Request
COMPONENT NAME

scaleway_ip_info

ADDITIONAL INFORMATION

New usage of the scaleway_ip_info module is as follows:

    - name: Get ip information and register it in a variable
      community.general.scaleway_ip_info:
        zone: it-mil-1
        api_token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      register: ips

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added merge_commit This PR contains at least one merge commit. Please resolve! module module needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html new_contributor Help guide this first time contributor labels Mar 20, 2026
@ansibullbot

This comment was marked as outdated.

@ansibullbot
Copy link
Copy Markdown
Collaborator

@ansibullbot ansibullbot added cloud integration tests/integration module_utils module_utils needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR plugins plugin (any type) tests tests and removed merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Mar 20, 2026
@ansibullbot
Copy link
Copy Markdown
Collaborator

cc @Lunik @guillaume_ro_fr
click here for bot help

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added the ci_verified Push fixes to PR branch to re-run CI label Mar 20, 2026
@philipnorton42 philipnorton42 marked this pull request as draft March 20, 2026 17:11
@ansibullbot ansibullbot added the WIP Work in progress label Mar 20, 2026
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-12 Automatically create a backport for the stable-12 branch labels Mar 21, 2026
Copy link
Copy Markdown
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@philipnorton42 philipnorton42 marked this pull request as ready for review March 23, 2026 12:17
@ansibullbot ansibullbot removed WIP Work in progress needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Mar 23, 2026
Copy link
Copy Markdown
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @philipnorton42

Thanks for your contribution! Couple of comments.

- Scaleway region to use (for example C(par1)).
required: true
- Scaleway region to use (for example V(par1)).
required: false
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required=false is redundant both here and in the arg specs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good call. Sorted them as well.

@russoz
Copy link
Copy Markdown
Collaborator

russoz commented Mar 23, 2026

Oh and please add a changelog fragment.

@felixfontein
Copy link
Copy Markdown
Collaborator

Also please note that the extra tests are failing.

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Mar 24, 2026
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Mar 24, 2026
@philipnorton42 philipnorton42 marked this pull request as draft March 24, 2026 09:55
@philipnorton42
Copy link
Copy Markdown
Author

Thanks for the feedback, I really appreciate it.
I've popped this PR back into draft whilst I get those changes in, and fix those tests.

@ansibullbot ansibullbot added the WIP Work in progress label Mar 24, 2026
Copy link
Copy Markdown
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry I didn't see this in time.

In any case, LGTM

@philipnorton42
Copy link
Copy Markdown
Author

Apologies for the delay in updating this.

I have added a change record for a minor_changes record for the addition of the zone parameter to the scaleway_ip_info module. After some problems (to do with my local environment) I was able to also get the nox tests to run, and committed the changes it made.

I think that's everything covered here. Please let me know if there is something I've missed :)

@philipnorton42 philipnorton42 marked this pull request as ready for review March 30, 2026 16:34
@ansibullbot ansibullbot removed the WIP Work in progress label Mar 30, 2026
@@ -0,0 +1,2 @@
minor_changes:
- scaleway_ip_info - now accepts a ``zone`` parameter, detailing the Scaleway zone to use in the lookup. This is mutually exclusive of the existing ``region`` parameter (https://github.com/ansible-collections/community.general/issues/11351).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- scaleway_ip_info - now accepts a ``zone`` parameter, detailing the Scaleway zone to use in the lookup. This is mutually exclusive of the existing ``region`` parameter (https://github.com/ansible-collections/community.general/issues/11351).
- scaleway_ip_info - now accepts a ``zone`` parameter, detailing the Scaleway zone to use in the lookup. This is mutually exclusive of the existing ``region`` parameter (https://github.com/ansible-collections/community.general/issues/11351, https://github.com/ansible-collections/community.general/pull/11629).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there should be entries for the changes in all the modules below.


def send(self, method, path, data=None, headers=None, params=None):
url = self._url_builder(path=path, params=params)
self.warn(url)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a bugfix? If yes, it should be mentioned in bugfixes: in the changelog fragment.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't think adding/removing log messages should count as a bugfix.

Now instead of removing this entirely, it might be worth replacing that with:

Suggested change
self.warn(url)
self.debug(url)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing the URL queried as a warning (which is likely very annoying to users of the modules) looks like forgotten debug code, and removing that would count (and should be announced to the users) as a bugfix IMO.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it looked like left over debugging code that wasn't removed. The fact that it just randomly prints the url being used inside the ansible logs without any context seemed to support this.

Changing this to self.module.debug() seems to be the preferred option from this module (and the rest of the codebase). I'll change it to that.

I did try to change it to use the verbosity flag of the ansible task (using display.vv() etc), but for some reason the library wasn't working on my environment. From what I read it's something to do with the underlying ansible-core library so debug() is probably the way to go (at least for now).

Copy link
Copy Markdown
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @philipnorton42

Thanks for your continued efforts here. 12.5.0 has left the building last week.

The new region in Italy is definitely something that could/should be backported to -12 and to -11, IMHO. That would be a bugfix.

The other changes would likely fall in the minor_changes category.

Not sure it's worth the effort of splitting this in two though.

type: str
description:
- Scaleway zone to use (for example V(nl-ams-1)).
version_added: 12.5.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That ship has sailed

Suggested change
version_added: 12.5.0
version_added: 12.6.0

@felixfontein
Copy link
Copy Markdown
Collaborator

The new region in Italy is definitely something that could/should be backported to -12 and to -11, IMHO. That would be a bugfix.

In the past, we alwasy treated new regions as a new feature.

Copy link
Copy Markdown
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another couple of comments


def send(self, method, path, data=None, headers=None, params=None):
url = self._url_builder(path=path, params=params)
self.warn(url)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't think adding/removing log messages should count as a bugfix.

Now instead of removing this entirely, it might be worth replacing that with:

Suggested change
self.warn(url)
self.debug(url)

@@ -0,0 +1,2 @@
minor_changes:
- scaleway_ip_info - now accepts a ``zone`` parameter, detailing the Scaleway zone to use in the lookup. This is mutually exclusive of the existing ``region`` parameter (https://github.com/ansible-collections/community.general/issues/11351).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there should be entries for the changes in all the modules below.

@philipnorton42
Copy link
Copy Markdown
Author

philipnorton42 commented Mar 31, 2026

So should I remove all of the updates for the new region and create a new issue for that?

Sorry, I saw the new region being added and thought I would include it, but I can always remove it and create a separate issue for it if that is best?

If not, I'll get the change records updated for this PR.

@russoz
Copy link
Copy Markdown
Collaborator

russoz commented Mar 31, 2026

I'd sayit hinges on the verdict for that warn(): if it sticks to a minor change, the new region is OK here, but you'll need to add entries for each module in the changelog fragment.

If it becomes a bugfix, then the region add should go to a different PR.

@felixfontein?

@felixfontein
Copy link
Copy Markdown
Collaborator

Why not simply move the warn change to another PR, instead of everything else?

@russoz
Copy link
Copy Markdown
Collaborator

russoz commented Apr 1, 2026

well, that would make life much easier :-)

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-12 Automatically create a backport for the stable-12 branch check-before-release PR will be looked at again shortly before release and merged if possible. cloud integration tests/integration module_utils module_utils module module new_contributor Help guide this first time contributor plugins plugin (any type) stale_ci CI is older than 7 days, rerun before merging tests tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants